Support required to understand a problem I've been facing with node red

hello guys. i have been working on node red for the past one month now and i use it to pass values to AOA by schneider electric. node red works fine and i have been able to pass values successfully.

the problem arises when i switch off the node red application or even the modbus simulator application and then switch it back on. i dont know if its a problem with node red or with the simulator but everytime i switch it back on, the same error keeps coming back on.

the error that pops up is

"Error: Cannot find module 'extend'
Require stack:

  • C:\Users\Admin.node-red\node_modules\node-red-augmented-operator\node_modules\request\index.js
  • C:\Users\Admin.node-red\node_modules\node-red-augmented-operator\node-red-augmentedoperator.js
  • C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\loader.js
  • C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\registry\lib\index.js
  • C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\runtime\lib\nodes\index.js
  • C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red\node_modules@node-red\runtime\lib\index.js
  • C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red\lib\red.js
  • C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red\red.js"

i have to uninstall and reinstall node.js, its files and node red all over to get it working again. it doesnt seem practical to do that every single time. what am i missing here?
Please help. Thanks guys

It is extremely unlikely that is necessary.

It is more likely your path arguments are not set so when you open a new terminal & execute node-red to kick it off, the path var isnt set correctly & node or node-red or something isnt found.

Having said that - this looks suspiciously incorrect (missing \ after admin)...

  • C:\Users\Admin.node-red\node_modules\node-red-augmented-operator\node_modules\request\index.js

Is this node-red-augmented-operator node in NPM? GIT?

How did you install that node (if by commandline, please paste that here exactly as you do to install it)

Look at the path - there is an error in the path. Uncertain how that is happening but it looks like the node-red loader is looking in the wrong place. That may or may not be an issue with node-red loader.js logic. Is this a custom node? What does the entry in package.json look like for that particular node?

Why do you say there is an error? It is using C:\Users\Admin.node-red as the user dir. That's entirely possible.

Clearly that directory exists and is where the extra nodes have been installed.

What is strange is the error is coming from loading a module that is two levels deep in the hierarchy - node-red-augmented-operator (which doesn't appear to be a publicly published module) has successfully loaded the request module. In turn the request module is trying to laod the extend module - and that's where its failing.

npm should have got all of the modules installed into the right place to begin with. It is very strange that one module would go missing across a restart/reboot.

@Darius What version of node.js, npm and node-red are you using?

OK, I suppose it is bit of an assumption since below that entry you can see C:\Users\Admin\AppData

I guess it would make sense at this point to ask if the OP really HAS the node-red files in C:\Users\Admin.node-red or C:\Users\Admin\.node-red because if the standard instructions had been followed, the .node-red directory would normally be created in C:\Users\Admin\.node-red

@Darius using file explorer - can you check where node-red is actually installed?
Also, can you provide the command line you use to start node-red?

It isn't about where Node-RED has been installed - its about where it has located the user directory.

I have seen it end up being C:\Users\Admin.node-red without the \ in the past. Hence my question about version of Node-RED.

@Steve-Mcl & @knolleary
Thanks for the reply guys. like you said, it is indeed strange that the whole error pops up while rebooting the application. the only viable solution i have found so far is uninstalling everything including the entire node modules installed previously, the npm cache and everything remotely related to it and reinstalling node.js and node red after

also, node-red-augmented-operator is not a publicly published module. i manually put the files required for the particular module that came along with the AOA files in the node-red node modules file.

also, as for the versions, i'm running v12.15.0 of node and npm is 6.13.4
i followed all the steps as mentioned in the installation page of node-red.

Error: Cannot find module 'extend'
Require stack:
- C:\Users\Admin\.node-red\node_modules\node-red-augmented-operator\node_modules\request\index.js
- C:\Users\Admin\.node-red\node_modules\node-red-augmented-operator\node-red-augmentedoperator.js
- C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\registry\lib\loader.js
- C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\registry\lib\index.js
- C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\runtime\lib\nodes\index.js
- C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\runtime\lib\index.js
- C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red\lib\red.js
- C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red\red.js

.node-red is installed in :C in admin. It was a mistake when copying the error

As for the error, all the files do exist in the specified paths. I dont understand how the "module extend stack required" comes up afterwards.

Ahh yes - the forum is stripping of the \ in the path - when I look at the raw text of your post, the \ is there. I've edited your post to display the text as code - which stops the forum from escaping those characters.

So the path is indeed C:\Users\Admin\.node-red\

After you do a clean install, take a copy of C:\Users\Admin\.node-red\package-lock.json
Have a look in that file for any reference to extend - take a note of any paths it references.

After a restart, and you hit the error, check to see if the package-lock.json file has changed at all. If you were able to identify any paths related to the extend module - check to see if the files still exist.

@Steve-Mcl & @knolleary
Hi guys. I figured it out. It was just missing modules which i had to individually install using npm. What confused me was how it worked properly on the first run and stopped after a reboot. Thanks though guys

I have currently the same issue you had and I am wondering exactly what you have done and which missing modules needed to be manually installed with npm.
Thank you in advance.

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