After the installation of Nodejs(20.9.0) on my laptop, whenever I am checking for node version in my cmd it shows the correct version but on checking for the npm version, it is throwing an error which i am not able to solve.
node:internal/modules/cjs/loader:1051
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
at Module._load (node:internal/modules/cjs/loader:901:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.9.0
node:internal/modules/cjs/loader:1051
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
at Module._load (node:internal/modules/cjs/loader:901:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.9.0 How do it deal with it?
- I have tried uninstalling and reinstalling the whole of Node but it doesn't seem to work.
- I tried some other methods suggested by ChatGPT, but they also don't work in my case.
Check your system variables for node path. This normally happens due to the wrong path for node in system variables. In my case, I was pointing to:
and the path it should ideally be pointing is to :
Fixing this system variable path resolved the issue for me.
If the above did not work try finding your nodejs and setting this in Adminstratpr Terminal like below: