12

i was actually trying to install nodejs along with npm on my ubuntu 17.04. i downloaded linux version from nodejs.org and created soft link for node and nodejs. upon checking the version of nodejs it shows the version i installed and i'm fine with it.

now i tried to do same for npm. i tried to create soft link for npm.

 sudo ln -sf /mnt/7A46BE1454633621/softwares/programming/frontend/nodejs/lib/node_modules/npm/bin/npm 
    /usr/bin/npm

i don't know the link i created is correct or not. but upon running npm -v command i see the version 5.0.3 which is what i am trying to install. the version is shown but right below it i see something like this.

5.0.3
npm update check failed                 │
│           Try running with sudo or get access           │
│          to the local update config store via           │
│ sudo chown -R $USER:$(id -gn $USER) /home/sagar/.config 
  • Did you sudo chown -R $USER:$(id -gn $USER) /home/sagar/.config as advised? – George Udosen Jun 15 '17 at 4:08
14

My npm version is 5.0.3 and I have the same problem when I use any npm command:

npm error message

The command is working fine but this code keeps showing up for no apparent reason. I've updated from 5.0.3 to 5.2.0 with these commands:

sudo chown -R $USER:$(id -gn $USER) /home/sagar/.config

npm install -g npm or npm i -g npm.

Now npm is working fine.

  • Worked for me. Although, I had to update npm as root with sudo npm i -g npm. Updated npm to 6.0.1 – Denialos May 20 '18 at 12:35
3

Exact same issue for me, but doesn't seem related to the version (I'm using npm 5.5.1). Fixing the rights on ~/.config made the trick for me:

sudo chown -R $USER:$(id -gn $USER) ~/.config

I guess this is related to some owner issue with ~/.config/configstore/update-notifier-npm.json.

1

I had change the owner of

~/configstore

and

~/configstore/update-notifier-npm.json

to $USER:$USER .

My guess is that running npm with sudo created that file. On my system at least we find this:

$ env | grep  -e HOME= -e "^USER="
USER=craig
HOME=/home/craig

$ sudo env | grep  -e HOME= -e "^USER="
HOME=/home/craig
USER=root

So if sudo npm is coded to create ~/configstore/update-notifier-npm.json it's going to do it the ordinary user's home directory. That creates a problem when later running npm without sudo which also wants to read and maybe write ~/configstore/update-notifier-npm.json. For some reason the permissions are 600 on both.

Be cautious when chown and chmod -ing everything under ~/.config, there might be something sensitive there.

0

Well, first thing we can do to solve this issues is

  1. Make sure you have ticked an option in folder setting to see hidden files.
  2. Right click on .config file and select properties and then click on permissions tab.
  3. In folder permissions and file permissions for group | owner | others tick the read, write and execute options.
  4. AT the bottom click on Apply permissions to enclosed files.
  5. Now try to rerun the same npm commands where you were seeing those messages and now it should be gone forever.

If this helped you know what to do.

Note: Same procedure can also be applied for configstore alone within .config folder.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.