On a new machine, I installed node.js and when I went to install a package, it would hit me with this error:
`PS C:UsersuserDesktopCC> npm nuxi init nuxt-dojo
node:internal/modules/cjs/loader:1205
throw err;
^
Error: Cannot find module ‘C:UsersuserAppDataRoamingnpmnode_modulesnpmbinnpm-cli.js’
at Module._resolveFilename (node:internal/modules/cjs/loader:1202:15)
at Module._load (node:internal/modules/cjs/loader:1027:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:187:14)
at node:internal/main/run_main_module:28:49 {
code: ‘MODULE_NOT_FOUND’,
requireStack: []
}
Node.js v22.0.0`
Upon further investigation, this would result in an error with any command starting with npm
.
Solution
I was missing the npm
folder in C:UsersuserAppDataRoaming
. So my solution was to create a new folder inside C:UsersuserAppDataRoaming
called npm
and then copy from my nodejs folder in C:Program Filesnodejs
and copy the node_modules
folder over into that npm
folder I made in C:UsersuserAppDataRoaming
. After I did that, I went back to the terminal in VSC and tried to install my package, and it started to work again.
Mitchell Karan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.