ioBroker / ioBroker.node-red

Instantiate the server with node-red
Apache License 2.0
52 stars 27 forks source link

npm module installation fails with scoped modules #425

Closed holomekc closed 6 months ago

holomekc commented 6 months ago

Adding for example the following module to the instance configuration: @node-red-contrib-themes/theme-collection

fails with:

Starting node-red: --max-old-space-size=512 /opt/iobroker/node_modules/node-red/red.js -v --settings /opt/iobroker/iobroker-data/node-red/settings.js
Error loading settings file: /opt/iobroker/iobroker-data/node-red/settings.js
node-red exited with 0

Logs are set to "All"

klein0r commented 6 months ago

Which adapter version is used? Please provide more information

holomekc commented 6 months ago

Node: 18.19.0 Npm: 10.2.3 Iobroker: 5.x (i cannot see it right now on my iPhone) Node-red adapter: 4.0.3

holomekc commented 6 months ago

This seems to work: https://github.com/ioBroker/ioBroker.node-red/blob/b6d11f2e9af75c39acb0a258d1fe0a4760517040/main.js#L313-L321

 for (let a = 0; a < additional.length; a++) { 
     if (additional[a].startsWith('node-red-') || additional[a].startsWith('@node-red-')) { 
         continue; 
     } 
     npms += `        "${additional[a]}": require("${dir}${additional[a]}")`; 
     if (a !== additional.length - 1) { 
         npms += ', \r\n'; 
     } 
 } 

Not sure what implications this might have though. The code changed in 5.x, but I think logically it is the same except the linebreaks.