Whenever I try to install npm-registry-client, I get the error "Error: Cannot find module 'npm-registry-client'".
I have tried to solve this with the following commands, but this did not work:
npm uninstall
npm install -g npm@latest
The full output is:
user@pc ~/devel> npm install npm-registry-client --save
module.js:340
throw err;
^
Error: Cannot find module 'npm-registry-client'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/cache/caching-client.js:9:22)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Getting the above on every npm procedure I tried so far. It appeared after updating npm
To fix the Cannot find module error, simply install the missing modules using npm . This will install the project's dependencies into your project so that you can use them. Sometimes, this might still not resolve it for you. In this case, you'll want to just delete your node_modules folder and lock file ( package-lock.
The "Cannot find module" error in Node. js occurs for multiple reasons: Forgetting to install a third-party package with npm i somePackage . Pointing the node command to a file that doesn't exist. Having an outdated version of the package, or an IDE or development server glitch.
To solve the "Cannot find module path or its corresponding type declarations" error, install the types for node by running the command npm i -D @types/node . You can then import path with the following line of code import * as path from 'path' .
It seems to be a bug in [email protected]. you should try upgrading from [email protected] directly to npm@next, which will bypass the buggy versions of npm. If you're currently stuck with a broken npm, and you can get back to a working npm by reinstalling Node.js.
The best way to jump over this problem is to reinstall Node using an official Node installer (not Homebrew) and use the packaged npm to upgrade straight to npm@next.
To reinstall Node.js:
rm -rf /usr/local/lib/node_modules
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With