Module_not_found error for local node, but not for released node

Hi all,

I have written a node and released updates several times without issue. Now I want to update the module some more, but it has been a while. Anyway, long story short, when I use palette manager to install my node there are no issues. However, when I clone my github repository to my local RPi4 to modify the code (using VSCode) and try to install the modified node locally, suddenly I get the following error:

Welcome to Node-RED
===================
18 Nov 16:50:53 - [info] Node-RED version: v3.0.2
18 Nov 16:50:53 - [info] Node.js  version: v16.20.2
18 Nov 16:50:53 - [info] Linux 6.1.21-v8+ arm LE
18 Nov 16:50:55 - [info] Loading palette nodes
redPlc rpi_mcp23008 driver V1.0.6 (c) Ocean iiot2k@gmail.com
18 Nov 16:50:56 - [info] Dashboard version 3.2.0 started at /ui
18 Nov 16:50:56 - [warn] ------------------------------------------------------
18 Nov 16:50:56 - [warn] [@joe-ab1do/mcp-pcf-aio/mcp-pcf-aio] Error: Cannot find module 'i2c-bus'
Require stack:
- /home/pi/dev/MCP230xx-PCF857x-AIO/mcp-pcf-aio.js
- /usr/lib/node_modules/node-red/node_modules/@node-red/registry/lib/loader.js
- /usr/lib/node_modules/node-red/node_modules/@node-red/registry/lib/index.js
- /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/index.js
- /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/index.js
- /usr/lib/node_modules/node-red/lib/red.js
- /usr/lib/node_modules/node-red/red.js
18 Nov 16:50:56 - [warn] ------------------------------------------------------
18 Nov 16:50:56 - [info] Settings file  : /home/pi/.node-red/settings.js
18 Nov 16:50:56 - [info] Context store  : 'default' [module=memory]
18 Nov 16:50:56 - [info] User directory : /home/pi/.node-red
18 Nov 16:50:56 - [warn] Projects disabled : editorTheme.projects.enabled=false
18 Nov 16:50:56 - [info] Flows file     : /home/pi/.node-red/flows.json
18 Nov 16:50:57 - [warn]
---------------------------------------------------------------------

The i2c-bus module is present in ~./node-red/node_modules. To be sure, I did npm-remove i2c-bus followed by npm-install i2c-bus, but same result. The node-red palette shows Module_Not_Found.

Using the palette manager, I can remove the node and successfully install the old (current) version from npm. I don't understand why suddenly the i2c-bus module cannot be found for the local node. I have changed nothing in the .js file.

How did you install local clone?

Did you run npm install inside the clone ?

1 Like

All I did was click on clone a repository using VScode. I installed it locally in ~/dev, a directory I had created. The directory was empty (newly created) prior to the clone install.

Details please - surely you ran npm install ~/dev/my-node-path ?

You also need to do this :point_up:

Also you need to restart node-red

Yes. I cloned the repository to the local folder ~/dev which downloaded the existing .js, .html, etc files from my repository to the ~/dev/(name of my repository) folder. Then after making a few modifications in the .html file I went to ~/.node-red folder and ran npm install ~/dev/(name of repository).

Don't know what this means. Can you elaborate?

Yes, I would always run node-red-restart. Lately I have been running node-red-stop and node-red-start in succession, which would give me the log.

It is probably the reason for your error. You typically need to run NPM inside the repository to grab its own dependencies.

e.g.

cd ~/dev/repo-folder
npm install

This will install any dependencies the clone needs

1 Like

Yup, that did it :slightly_smiling_face:

Thanks so much (again).

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