Can not install external nodes in embedding mode

#1

Hi there,

i'm new to nodered. I followed the documents about embedding nodered in an express app, and it worked.

My settings:

var settings = {
  httpAdminRoot: "/red",
  httpNodeRoot: "/redapi",
  userDir: "~/.node-red/",
  functionGlobalContext: {}    // enables global context
};

But when i tried to install external nodes in nodered userDir using:

npm install node-red-contrib-mongodb

the installed node did not show in the panel.

When i tried to install using menu, it reports an error:

The express console reported this error:

5 Dec 11:01:29 - [info] Installing module: node-red-contrib-mongodb, version: 0.3.4
5 Dec 11:01:34 - [info] Installed module: node-red-contrib-mongodb
POST /red/nodes 400 5281.048 ms - 86

I did some digging, and found the exact error is:

{ Error: Cannot find module 'node-red-contrib-mongodb'
    at Object.getModuleFiles (/Users/zhuxichi/Documents/GitHub/kgserver_v2/node_modules/node-red/red/runtime/nodes/registry/localfilesystem.js:350:19)
    at Object.addModule (/Users/zhuxichi/Documents/GitHub/kgserver_v2/node_modules/node-red/red/runtime/nodes/registry/loader.js:395:43)
    at Object.addModule (/Users/zhuxichi/Documents/GitHub/kgserver_v2/node_modules/node-red/red/runtime/nodes/registry/index.js:41:19)
    at ChildProcess.child.on (/Users/zhuxichi/Documents/GitHub/kgserver_v2/node_modules/node-red/red/runtime/nodes/registry/installer.js:140:52)
    at ChildProcess.emit (events.js:182:13)
    at ChildProcess.EventEmitter.emit (domain.js:442:20)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5) code: 'MODULE_NOT_FOUND' }

It's quite weird because there is no problem when i use a standalone node-red instance. Anything wrong with my settings?

0 Likes

#2

Oh, I tried calling npm install in my project root dir and it seems worked.

0 Likes