# Unittest node helper and npm dependency issues

**URL:** <https://discourse.nodered.org/t/unittest-node-helper-and-npm-dependency-issues/72928>\
**Category:** Developing Nodes\
**Tags:** function-node, node-red-node-test-helper\
**Created:** [30 December 2022 07:20 UTC](https://discourse.nodered.org/t/unittest-node-helper-and-npm-dependency-issues/72928 "2022-12-30T07:20:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kakyoism](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kakyoism/32/46283_2.png) [@kakyoism](https://discourse.nodered.org/u/kakyoism)\
**Post date:** [30 December 2022 07:20 UTC](https://discourse.nodered.org/t/unittest-node-helper-and-npm-dependency-issues/72928/1 "2022-12-30T07:20:09Z")

</div>

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's `package.json`
- run `npm install /path/to/npm/node_modules/node-red --no-save`, as per [the instruction on `node-red-node-test-helper` README](https://github.com/node-red/node-red-node-test-helper)
- 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. 🙏

---

<div class="post-metadata">

**Author:** ![kakyoism](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kakyoism/32/46283_2.png) [@kakyoism](https://discourse.nodered.org/u/kakyoism)\
**Post date:** [3 January 2023 06:33 UTC](https://discourse.nodered.org/t/unittest-node-helper-and-npm-dependency-issues/72928/2 "2023-01-03T06:33:42Z")

</div>

Currently, I just have to write `node-red` as a dev-dependency in the `package.json` in a wrapper package, and completely forget about using a pre-installed node-red.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 March 2023 06:34 UTC](https://discourse.nodered.org/t/unittest-node-helper-and-npm-dependency-issues/72928/3 "2023-03-04T06:34:17Z")

</div>

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