'npm init shows code: 'MODULE_NOT_FOUND', after installing nvm
I was already using node version 8.12.0. Then I installed nvm to use latest version of node (13.6.0). I ran cmd nvm use 13.6.0 . Now node is using latest version. Later on when I when tried npm init I see this error
npm init
internal/modules/cjs/loader.js:976
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:973:15)
at Function.Module._load (internal/modules/cjs/loader.js:855:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
internal/modules/cjs/loader.js:976
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:973:15)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:855:27)[39m
[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)[39m
[90m at internal/main/run_main_module.js:17:47[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: []
}
To solve this I adding each version path to system variable path
Solution 1:[1]
I was facing the same problem, then realized was running from different directory then I cd into that and ran again and it worked. Hope it will work for you too. basically it was where file were located when you run it. See how its worked for me
Solution 2:[2]
I got the same kind of issue, was not able to install any modules using npm or npx.And what i did was, i uninstalled the nodejs then i deleted the node path. After i installed the nodejs again and now it's working as usual.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Kartik Patel |
Solution 2 | Harichandra kishor |