Hi!
I'm developing a project in which I got Node-RED embedded inside Node.js, so Node-RED starts up when I start the Node.js server.
The Node-RED dir has its own package.json. The directory structure is the following:
asd
.
├── .nodered/
│ └── package.json
│ └── node-red-contrib-s7/ (or any other module)
│
└── package.json
└── node-red/
The problem happens with any module, not only with 'node-red-contrib-s7'. So the problem is, when I install a package from terminal (being inside .nodered/) with 'npm install whatever', apparently it installs correctly, but updating Node-RED does not show the new modules, and I can't see them inside the Pallete Manager. If I search for them in the Install tabs inside the Pallete Manager, they show as not installed. If I press install, they following message appears:
Failed to install: node-red-contrib-s7
Cannot find module 'node-red-contrib-s7'
Check the log for more information
The weird thing is that the packages ARE in the package.json (in the one inside .nodered/ ), so they've been correctly installed. I also tried this last step (installing from Pallete manager) after uninstalling the module from .package.json, and didn't work. Also, if I go to the log in the Palette Manager, it does not show any error, it installs the package correctly:
2020-02-06T08:47:32.344Z npm install --no-audit --no-update-notifier --save --save-prefix="~" --production node-red-contrib-s7@2.1.1
2020-02-06T08:47:34.821Z [out]
2020-02-06T08:47:34.821Z [out] > usb@1.6.2 install /Users/javier.marzan/tfg/back/.nodered/node_modules/usb
2020-02-06T08:47:34.821Z [out] > prebuild-install --verbose || node-gyp rebuild
2020-02-06T08:47:34.821Z [out]
2020-02-06T08:47:34.996Z [err] prebuild-install
2020-02-06T08:47:34.997Z [err]
2020-02-06T08:47:34.997Z [err] info begin
2020-02-06T08:47:34.997Z [err] Prebuild-install version 5.3.3
2020-02-06T08:47:35.000Z [err] prebuild-install
2020-02-06T08:47:35.000Z [err] info looking for cached prebuild @ /Users/javier.marzan/.npm/_prebuilds/73a0d1-usb-v1.6.2-node-v64-darwin-x64.tar.gz
2020-02-06T08:47:35.001Z [err] prebuild-install
2020-02-06T08:47:35.001Z [err] info found cached prebuild
2020-02-06T08:47:35.001Z [err] prebuild-install info
2020-02-06T08:47:35.001Z [err] unpacking @ /Users/javier.marzan/.npm/_prebuilds/73a0d1-usb-v1.6.2-node-v64-darwin-x64.tar.gz
2020-02-06T08:47:35.020Z [err] prebuild-install
2020-02-06T08:47:35.020Z [err] info unpack resolved to /Users/javier.marzan/tfg/back/.nodered/node_modules/usb/build/Release/usb_bindings.node
2020-02-06T08:47:35.027Z [err] prebuild-install
2020-02-06T08:47:35.027Z [err] info unpack required /Users/javier.marzan/tfg/back/.nodered/node_modules/usb/build/Release/usb_bindings.node successfully
2020-02-06T08:47:35.027Z [err] prebuild-install
2020-02-06T08:47:35.027Z [err] info install Successfully installed prebuilt binary!
2020-02-06T08:47:35.129Z [out] + node-red-contrib-s7@2.1.1
2020-02-06T08:47:35.129Z [out] added 64 packages from 46 contributors in 2.2s
2020-02-06T08:47:35.153Z rc=0
And everytime, package is correctly shown inside package.json. This leads me to think that in some way, Node-RED is not pointing to the correct directory for modules, which is weird because I didn't manually change anything in the direct structure that Node-RED created. I also tried to install the packages in the other package.json just in case, and it didn't work either. I didn't find any setting for changing where Node-RED searches for modules.
So I'm a bit lost right now. Any help? Thanks in advance!