Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

msassa's avatar
Level 18

Use a custom npm module into a Nova Tool

Hello, I build a couple of tools in Nova, and I need to make an npm module with some methods, common to all the tools. For example, call to an API.

So, I created a new folder into the nova-components called DatasetSharedFiles:

nova-components/DatasetSharedFiles/package.json

{
  "name": "datasetsharedfiles",
  "version": "1.0.0",
  "description": "Shared files between Datasets Components",
  "main": "dist/bundle.js",
  "scripts": {
    "build": "webpack",
    "watch": "npm run build -- --watch"
  },
  "author": "Mauro Sassaroli",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^5.65.0"
  }
}

nova-components/DatasetSharedFiles/index.js

function getItems () {
			... ...
}
function setItems () {
			... ...
}

export default {
    getItems: getItems,
    setItems: setItems
}

Then I installed that module to the nova tool, making npm install --save ../DatasetSharedFiles

That command makes a symlink from nova-components/DatasetSharedFiles to my nova-components/DatsetForm/node_modules/DatasetSharedFiles and I think that is OK.

Next, I imported the module from the Tool.vue using import sharedMethods from 'datasetsharedfiles';

Bur here the problems start.

1- I get some errors when I try to compile the tool, about babel.

  • Module build failed: ReferenceError: Unknown plugin "transform-runtime" specified in "base" at 1
  • So I installed npm install babel-plugin-transform-runtime --save-dev.

2- I get errors about another module

  • Module build failed: Error: Couldn't find preset "env" relative to directory
  • So I installed npm install babel-preset-env --save-dev

3- Finally I can build the tool without errors, but the sharedMethods do not contain the methods, if I do a console.log from that, I get an object but no methods inside.

Is the first time I try to do something like this, and I can be sure what I'm doing wrong.

Can anyone help me with this? Thanks !!

0 likes
0 replies

Please or to participate in this conversation.