I'm facing a weird npm dependency issue when trying to install node-red-node-test-helper
with custom nodes and a globally installed Node-RED v2.0.5.
The expected dependency situation is like this:
- All custom nodes share one globally-installed Node-RED v2.0.5
- Each custom node package depends on
node-red-node-test-helper
as dev-dependency - Those custom node package does not have to depend on Node-RED in its
package.json
explicitly
In my practice, I'm getting complaints about missing node-red dependency when running npm test
after doing the following:
- add
node-red-node-test-helper
as dev-dependency to a custom node'spackage.json
- run
npm install /path/to/npm/node_modules/node-red --no-save
, as per the instruction onnode-red-node-test-helper
README - optional: add more dependencies to
package.json
- run
npm install
under that node package directory
Also, if I npm install -g jest
AFTER installing node-red
globally, I get the same issue and have to reinstall node-red
.
I also tried to wraps up the helper into a utility package without installing this package globally, and let all the other nodes share the utility code through require('/path/to/util')
, and will get the same "missing node-red" problem with that utility package itself.
The only sure fix I can find is to add node-red
as a dev-dependency to all custom node packages. But that seems a huge baggage to carry if we eventually have hundreds of nodes.
I must admit that I'm not 100% sure what I'm doing when installing npm dependencies, but I'd appreciate some pointers on what I'm missing.