Home » Nodejs » Error: Cannot find module 'npm-registry-client'

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

Posted by: admin November 29, 2017 Leave a comment

Questions:

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 [email protected]

The full output is:

[email protected] ~/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

Answers:

It seems to be a bug in [email protected] you should try upgrading from [email protected] directly to [email protected], 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 [email protected]

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

Questions:
Answers:

I believe npm-registry-client is a separate package.

Have you tried npm install npm-registry-client --save ?

https://www.npmjs.com/package/npm-registry-client

edit: It looks like your npm is just plain broke.

Maybe these steps will help:

rm -rf ./node_modules
npm install

Questions:
Answers:

Had same problem. I’m using Ubuntu.
Steps that I’ve done:

  1. deleted folder /usr/lib/node_modules
  2. reinstalled nodejs using this help nodejs
  3. updated npm to latest stable using sudo npm update -g npm

Basicly you have to reinstall nodejs 🙁 Nothing else helped.
P.S. just in case: save somewhere list of packages which you need, just listing node_modules folder(ls -l /usr/lib/node_modules) and saving output. So you can reinstall them later.

Questions:
Answers:

I had the same problem on Windows and found that the node uninstaller left the cache in place in AppData/Roaming.

This worked for me:

  1. Uninstall Node
  2. Remove npm and cache by hand
  3. Reinstall from the msi on the official Nodejs website
Questions:
Answers:

I’ve solved this problem just by using npm 3.5.0

sudo npm install -g [email protected]

I had this problem when I tried to install atom-editor on archlinux from AUR repository with npm 3.4.1

Questions:
Answers:

I also encountered the same issue while working with Protractor tool. What I did was that I tried to update npm 3.4.1 to latest(this being the latest), and did it twice with below command twice:

npm install -g npm

So, something went wrong in the npm 3.4.1 and the above error kept coming.

Some issues add for this on github: https://github.com/npm/npm/issues/10492, https://github.com/npm/npm/issues/10394 and https://github.com/npm/npm/issues/2528.

Solution is to Reinstall the Nodejs by removing all the file associated with it.

Make sure you:

  1. Restart the machine after uninstalling the nodejs.
  2. Delete the following files if not already done:

    C:\Program Files (x86)\Nodejs
    C:\Program Files\Nodejs
    C:\Users\{User}\AppData\Roaming\npm (or %appdata%\npm)
    C:\Users\{User}\AppData\Roaming\npm-cache (or %appdata%\npm-cache)
    
  3. Install using the node installer.

Refer: https://stackoverflow.com/a/20711410/3619412

Questions:
Answers:

I had the same problem on my mac and the solution for me was uninstall my node.js and npm modules following the steps from this link:

  1. go to /usr/local/lib and delete any node and node_modules
  2. go to /usr/local/include and delete any node and node_modules directory
  3. if you installed with brew install node, then run brew uninstall node
    in your terminal
  4. check your Home directory for any local or lib or include folders,
    and delete any node or node_modules from there
  5. go to /usr/local/bin and delete any node executable

Also I did this:

  1. sudo rm /usr/local/bin/npm
  2. sudo rm /usr/local/share/man/man1/node.*
  3. sudo rm /usr/local/lib/dtrace/node.d
  4. sudo rm -rf ~/.npm
  5. sudo rm -rf ~/.node-gyp
  6. sudo rm /opt/local/bin/node
  7. sudo rm /opt/local/include/node
  8. sudo rm -rf /opt/local/lib/node_modules

Then I reinstalled a clean version of node.js. In my case is the version 5.1.0 which I downloaded from here

Questions:
Answers:

Official Joyent Docs are outdated

We need to ditch tldr mentality for this one and get lastest information about setup_x.x before contintuing.

Piping curl setup_x.x to bash fails

Furthermore official Joyent Docs use curl and pipe to bash -E, which fails for me. Hence we are going to use wget.

Apt-get the lastest node package

After reading above paragraphs, you can now follow this:

sudo apt-get remove node npm nodejs -y
sudo rm -rf /usr/local/lib/node_modules  
sudo wget https://deb.nodesource.com/setup_0.12
sudo -E bash ./setup_0.12
sudo apt-get install nodejs -y
sudo npm -g install [email protected]

nodejs --version now should print latest one, e.g.

v0.12.9

Compile from Source

If nothing helps, as in my case, you want to go oldschool and compile from source:

sudo apt-get remove node npm nodejs -y
sudo rm -rf /usr/local/lib/node_modules
mkdir ~/node && cd ~/node
wget http://nodejs.org/dist/v0.12.9/node-v0.12.9.tar.gz
tar -xzvf node-v0.12.9.tar.gz
./configure && make
sudo make install

Questions:
Answers:

I had a very similar issue. Removing the entire node_modules folder and re-installing worked for me. Hope it will help you.

rm -rf node_modules
npm install

Leave a Reply

Your email address will not be published. Required fields are marked *