NPM Command Not Found

Hello! My name is Noah, a relatively new user to Node-red.

I am running into an issue, seemingly something to do with the file directories which node-red uses to run.

I am running on Windows 10 (21H1) with Node v16.17.1 and npm v8.15.0

I have tried 5 (or so) times to wipe and re-install Node.js after the following error when running node-red:

C:\WINDOWS\system32>node-red
30 Sep 14:29:34 - [info]

Welcome to Node-RED

30 Sep 14:29:34 - [info] Node-RED version: v3.0.2
30 Sep 14:29:34 - [info] Node.js version: v16.17.1
30 Sep 14:29:34 - [info] Windows_NT 10.0.19043 x64 LE
30 Sep 14:29:34 - [info] Palette editor disabled : npm command not found
30 Sep 14:29:34 - [info] Loading palette nodes
30 Sep 14:29:35 - [info] Settings file : C:\Users\nomar.node-red\settings.js
30 Sep 14:29:35 - [info] Context store : 'default' [module=memory]
30 Sep 14:29:35 - [info] User directory : \Users\nomar.node-red
30 Sep 14:29:35 - [warn] Projects disabled : editorTheme.projects.enabled=false
30 Sep 14:29:35 - [info] Flows file : \Users\nomar.node-red\flows.json
30 Sep 14:29:35 - [info] Creating new flow file
30 Sep 14:29:35 - [warn]

If you did not catch it, the npm command is not found, meaning the palette editor is missing when I try to add modules to my flows.

So far, I have tried the following:

Adding the directory for npm-cli.js to the Path variable (via Windows System Environment Variables)
Adding the directory for Program Files > nodejs to the Path variable
Adding the directory for .node-red to the Path variable

I have spent 6+ hours looking for a fix on forums, and have tried more than what is listed above.

This is the only system I run into this problem on. I have a RasPi running node-red fine as well as another Windows 10 system.

Any help would be much appreciated. Thanks!

What do you get when you run npm -v in the command prompt ?

I get an error, see below:

node:internal/modules/cjs/loader:959
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
node:internal/modules/cjs/loader:959
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
←[90m    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)←[39m
←[90m    at Function.Module._load (node:internal/modules/cjs/loader:804:27)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)←[39m
←[90m    at node:internal/main/run_main_module:17:47←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: []
}

Since you are on windows

  1. Uninstall nodejs
  2. clean whatever Paths are related to nodejs and npm in Enviroment Variables (for User and System)
  3. then try to re-install nodejs

Hi,

I think this is a 'paths' issue. When you install Node JS on Windows you get a new Start menu item: Node.js. Within that there is a sub-menu to run the (properly configured) Node shell that you would then use to run Node-RED. It even displays in the header that it is properly configured to run Node applications.

Running a shell that starts in C:\WINDOWS\system32> tells me you are not doing this.

I would NOT de-install / re-install until I'd tried those steps first - it possibly would work already, simply the paths are not configured as needed.

Cheers,

Paul

ok .. if it helps these are the nodejs and npm Paths in my Windows Environmental Variables

For User --> Path
C:\Users\User\AppData\Roaming\npm
(replace User with your local user account)

For System --> Path
C:\Program Files\nodejs\

You don't need that if you installed node.js the way it is recommended on the node.js website. However, you do need to remember that updates to environment variables won't be seen in the current command line. You will need a new command line to see them.

If all else fails after installing node.js and it won't run in a new command line simply by typing node, log out and back in again.

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