Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module 'npm-registry-client'

Tags:

node.js

npm

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

like image 550
stevek-pro Avatar asked Nov 21 '15 23:11

stevek-pro


People also ask

How do I resolve Cannot find module error using node JS?

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.

What does Cannot find module mean?

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.

Can not find module node path?

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' .


1 Answers

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

Using Ubuntu

curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -

sudo apt-get install -y nodejs

Using Debian, as root

curl -sL https://deb.nodesource.com/setup_5.x | bash -
apt-get install -y nodejs
like image 112
Naveen Dahiya Avatar answered Oct 16 '22 16:10

Naveen Dahiya