Problem importing external libraries to node-red

Hello guys,

Im trying to deploy my node-red project in aws ec2 ubuntu server.
My project uses the built-in module crypto, i declare the module functionGlobalContext object in settings.js:

'Locally' everything works fine,but when pm2 starts the server and i test it with function node i get this:

Check the log output of pm2 - Node-RED logs the full path to the settings file it is using. It may be that under pm2 it's using a different userDir/settings file to the one you've edited.

following your tip, i found another settings.js file and edited it the same way:

but i still gets the same error

Can you share the opening lines of your log please? So we can see which file it is using and whether there are any other errors lurking. Thanks.

Using the command pm2 logrotate:

following the log response, i found the node-red folder:

inside the node-red folder, i edited the settings.js file

No, we need to see the opening lines of the Node-RED log. As you are using PM2, you can access the node-red log using pm2 commands. We need the section of the log from where node-red starts through to where the flows are active.

By the way, using PM2 to run node-red on a Ubuntu Linux OS is really not recommended for "live" running. PM2 is more useful for test instances. It adds a lot of unnecessary overheads for live use. Configure a systemd startup script instead. Dave's Raspberry Pi/Debian installer has the details. My alternate installer repo also has an example startup script.

Following root path, found another node-red folder and edited the settings.js file but still doesnt work

You need to go further back in the log to find the Welcome to Node Red message and the startup lines after that.
Please copy/paste log output rather than screenshot, it is easier to read.

We can't help unless you share all the information we've asked for.

Not sure why you are using PM2 and really not sure why you thought it best to install under root. Neither are recommended installations for Node-RED on Linux systems (there are some rare occasions when you might choose them - but really rare). You have made the installation more complex for yourself than you needed to and now are struggling to identify problem root-causes.

For reference, here is the startup of my node-red dev instance on Windows - it DOES use PM2.

0|Node-RED  | 21 Nov 21:07:38 - [info]
0|Node-RED  | Welcome to Node-RED
0|Node-RED  | ===================
0|Node-RED  | 21 Nov 21:07:38 - [info] Node-RED version: v3.0.2
0|Node-RED  | 21 Nov 21:07:38 - [info] Node.js  version: v16.14.0
0|Node-RED  | 21 Nov 21:07:38 - [info] Windows_NT 10.0.19044 x64 LE
0|Node-RED  | 21 Nov 21:07:39 - [info] Loading palette nodes
0|Node-RED  | 21 Nov 21:07:44 - [info] Dashboard version 3.1.7 started at /nr/ui
0|Node-RED  | 21 Nov 21:07:45 - [info] [wiser:wiser-class.js:setup] Setup fn complete
0|Node-RED  | 21 Nov 21:07:45 - [info] Settings file  : C:\src\nr\data\settings.js
0|Node-RED  | 21 Nov 21:07:45 - [info] HTTP Static    : C:\src\nr\public > /
0|Node-RED  | 21 Nov 21:07:45 - [info] Context store  : 'default' [module=memory]
0|Node-RED  | 21 Nov 21:07:45 - [info] Context store  : 'file' [module=localfilesystem]
0|Node-RED  | 21 Nov 21:07:45 - [info] User directory : C:\src\nr\data
0|Node-RED  | 21 Nov 21:07:45 - [info] Projects directory: C:\src\nr\data\projects
0|Node-RED  | 21 Nov 21:07:45 - [info] Server now running at http://127.0.0.1:1880/red/
0|Node-RED  | 21 Nov 21:07:46 - [info] Active project : uibuilder_next_gen
0|Node-RED  | 21 Nov 21:07:46 - [info] Flows file     : C:\src\nr\data\projects\uibuilder_next_gen\flow.json
0|Node-RED  | 21 Nov 21:07:46 - [warn] Using unencrypted credentials
0|Node-RED  | 21 Nov 21:07:46 - [info] +-----------------------------------------------------
0|Node-RED  | 21 Nov 21:07:46 - [info] | uibuilder v6.0.0-dev initialised
0|Node-RED  | 21 Nov 21:07:46 - [info] | root folder: /src/uibRoot
0|Node-RED  | 21 Nov 21:07:46 - [info] | Using custom ExpressJS webserver at:
0|Node-RED  | 21 Nov 21:07:46 - [info] |   http://172.30.32.1:3001 or http://localhost:3001/
0|Node-RED  | 21 Nov 21:07:46 - [info] | Installed packages:
0|Node-RED  | 21 Nov 21:07:46 - [info] |   @totallyinformation/web-components, vue
0|Node-RED  | 21 Nov 21:07:46 - [info] +-----------------------------------------------------
0|Node-RED  | 21 Nov 21:07:46 - [info] Starting flows
0|Node-RED  | 21 Nov 21:07:46 - [info] Started flows

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.