How to correctly import an npm module for a JavaScript action

0
Hello! Our application makes use of an npm module in a Javascript action. Once the package is manually installed using VSCode, the application runs perfectly. However, we haven't been able to configure our build to do this automatically.  Currently we have placed the package.json file in the root folder. We also tried placing it in the 'actions' directory of the JavaScriptSource folder for that action. Neither seems to work. We're hoping there's a way to ensure that the module is installed and compiled correctly so that the JavaScript action can find it. We are using Studio Pro version 9.24.11.   Thanks for any assistance in advance!
asked
1 answers
0

Hi Mignonne Maxwell,

 

Placing your package.json into the "actions" folder is not a good way to do that. Instead, you should create a new module specific for configuring the external library used in JS Actions. To create that module, please refer to the implementation of NanoflowCommons. Then you can build this module and publish it to Marketplace for other applications to reuse.

 

It is recommended officially by Mendix documentation for Using External Dependencies in the Browser.

 

Regards,

Dat

answered