I was working on a node js project.
Completely and utterly out of nowhere, node js started misbehaving somehow.
Suddenly ‘node is not a recognized command’…. wtf?
I rebooted and still it was messed up.
I forgot where/how I installed node but realized i had installed through scoop, so I ‘scoop uninstall node’ and ‘scoop install node’. It still was behaving strangely.
I just grabbed the windows installer from nodejs.org and finally it worked.
Except, until I needed to run ‘npm’.
node:internal/modules/cjs/loader:1205
throw err;
^
Error: Cannot find module 'C:UserspetteAppDataRoamingnpmnode_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
It’s looking for npm-cli.js in the wrong directory! It’s installed in C:Program Filesnpmnode_modulesbinnpm-cli.js!
How do I fix this?
I believe the cause of all this trouble may have been an accidental wipe of my $PATH env variable.
Thanks in advance.