I get a warning that npm update check failed - node.js

Following is the error message I get after installing npm packages
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/ubuntu/.config

Answer from GitHub:
Fix for windows, I got this message :
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)
C:\Users.config
so I went on to C:\Users.config and deleted the "configstore" folder.
once I done this, next time a ran npm start, the folder was
re-generated, and error stopped
Original answer
If you are on a Mac, this might help
sudo npm i -g npm

Related

How to reverse "sudo chown -R 501:20"

Ran npm i -g {library} inside my project and npm gave me an error because I didnt use sudo. instead of using sudo on a second attempt, I followed npm's suggestion to run sudo chown -R 501:20 "/Users/vorousjames/.npm" (inside my project).
now anytime I run an npm command (anywhere), I get bash: /Users/vorousjames/.npm-global/bin/npm: No such file or directory
How do I fix this so I can use npm again?
try running this in the terminal
export PATH="/Users/vorousjames/.npm:$PATH
if it works add that to your .bash_profile

fail to install electron in ubuntu

I followed the command 'npm install -g electron', the command line gives me back an error 'EACCES:permission denied, mkdir /usr/local/lib/node_modules/electron/.electron'
I tried to give permission by 'chown -R root /usr/local/lib/node_modules/*', but still doen't work?
anyone seen the problem before?
solved:
at last I found you can install it directly without root or sudo
If you are using the -g flag for global, you have to either run the command as the root user or invoke the command with sudo
sudo npm install -g electron

npm update check failed

Last night I tried to update my node and npm, it seemed to have been successful, however ever since then I have been getting this same error any time I try and run any npm command.
I have tried uninstalling and re-installing npm, but cannot get past this error message below.
Node version: v8.3.0
Error message I am getting:
┌───────────────────────────────────────────────────────────────────┐
│ 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) /Users/veritystothard/.config │
└───────────────────────────────────────────────────────────────────┘
module.js:491
throw err;
^
Error: Cannot find module 'proto-list'
at Function.Module._resolveFilename (module.js:489:15)
at Function.Module._load (module.js:439:25)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/config-chain/index.js:1:79)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
I'm not sure what other details to include here, if anyone has had this issue before I'd appreciate your help. Thanks!
Following is the answer from github
Fix for windows, I got this message :
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)
C:\Users.config
so I went on to C:\Users.config and deleted the
"configstore" folder. once I done this, next time a ran npm start, the
folder was re-generated, and error stopped
Fix for OSX:
After two hours of try-and-fail I managed to solve the issue as follows:
go to folder /usr/local/lib/node_modules/
right-click on the folder node_modules > go to Get Info
update the permissions > add yourself and administrator account and set "read and write" for both
run in the terminal "npm install packageName"
if you still get the error, go to the same folder /usr/local/lib/node_modules/ and within the folder node_modules, update in the same way the permissions for the new package folder
try to run again in the terminal "npm install packageName"
That worked for me! Hope it could help somebody.
I had the same issue on AWS server, i used this command to update the config permissions and the npm command worked smooth.
sudo chown -R $USER:$(id -gn $USER) ~/.config
If your are on macOS, you must update the config file. You just have to enter this command in your terminal:
sudo npm i -g npm
I have similar error after node updating so i just delete directory .config and this help.
Run below command from a command prompt
Step 1 : (If possible open cmd as administrator)
- npm install -g npm-check-updates
Step 2 :
- Open new command prompt and Create a new project
I got a Windows 10 environment:
For me, first I did make sure all node.exe instances killed:
taskkill /t /f /im node.exe
Then I've updated npm to the latest version using npm-check-updates
Finally, I deleted .config folder from user home C:\Users\<USERNAME>
That's solved my problem.
If you don't want to chown your entire .config directory (which contains configuration files from other programs), try:
sudo chown -R $USER:$(id -gn $USER) "/home/skaestle/.config/configstore/"
Try running the command prompt Run as administrator mode, if that not solved your issue delete the .config folder under c:\user\<name of the user>\ and then try running the command prompt Run as administrator mode.
I had the same error (npm update check failed) on a Centos 7 but not when installing node, just when loggin into the server and it was because there was no more space left. Deleted some files, updated the system and everything worked fine again.
Just in case somebody else comes to the same problem.
I have a fixed that worked for me on OSX Catalina:
-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
> node server.js
€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
│ 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) /tmp/.config │
└──────────────────────────â”
I ran the following code in the terminal and as suggested here: sudo chown -R $USER:$(id -gn $USER) /tmp/.config & redeployed to my instance which still showed a degraded state.
I did this several times and this did not result in success.
Since I had a duplicate instance that was in the ready, so I didn't think it was a permissions problem on my local machine.
The following fix worked for me (please note that my code is deployed to ebs through AWS CodePipeline":
Delete package-lock.json from your express/node project.
Run npm i
git add && git commit -m "your commit msg" && git push
In your aws console, go to code pipeline and verify your code deployed successfully.
Navigate to Elastic Beanstalk. If your code pushed successfully, you should see your instance updating.
After this the state of your EBS environment should be in the ready state.
Hope this helps someone out.
worked for me after running below command
nvm use --delete-prefix version
Running the cmd with admin rights once was enough for me.
Just did npm version.
After that it worked again also without admin rights.
I did not delete anything.
{
npm: '6.13.6',
node: '12.14.1',
...
}
If the user does not have sudo rights in a unix environment, remember the user name you want to issue the command with (-> USER). Then use
su
Enter your root password. Then
chown -R USER:USER .config
Other .config folders that were created using root are also changed. In my case changing ~/.config/nvws owner did the job (chown -R THE USER YOU USE NPM WITH:THE USER YOU USE NPM WITH .config/nvm)
I'm a windows user. I solved mine by going to the /Users/<username> right clicking the .config folder then in properties un-ticked the read only and apply
run script to check for update
sudo npm install -g npm-check-updates
and later update using sudo npm
This issues come due to TWO reasons
You have no permission to read-write
Due to window settings folder is secured.
case 1st- just enable the read-write permission
case 2nd- if u have permission for read-write and still you facing the same issues, it means you system securities reject the request to write the file, because the file location is given in C drive
solution - JUST disable the firewall / Ransomware protection in windows 10. try again you will get the success.

Fix for npm global install on Ubuntu

I have a nodejs package that requires a global install. This one fails in a way that leads me to believe there might be a configuration problem in the the Ubuntu package npm. This happens every-time I setup an Ubuntu 14.04 machine.
sudo apt-get install npm
npm install -g lineman
The npm -g command will throw some access error naming the local lib and bin directories. Unlike some global installs, it is not an option to cheat and run the second command under sudo. So, the only fix I have found that will work is something like this:
sudo chgrp -R $(whoami) /usr/local/bin /usr/local/lib
sudo chmod -R g+rwx /usr/local/bin /usr/local/lib
The fix is fine for me, I'm the only user. But is this really the best way to do it? I don't want to document my fix for anyone else that might use it in an environment where this will not work or cause trouble.
Also, should I file a bug report with someone who packages npm for Ubuntu?
Instead of npm install -g lineman, you should run sudo npm install -g lineman. npm requires permission as well.
Also check this stackoverlfow link.

NPM cannot install dependencies - Attempt to unlock something which hasn't been locked

I've been trying to run an npm install on my package.json file, but I'm having a lot of trouble. It keeps saying "Error: Attempt to unlock XXX, which hasn't been locked" on all my dependences. Here's one of them:
Error: Attempt to unlock tbd#~0.6.4, which hasn't been locked
at unlock (/usr/local/lib/node_modules/npm/lib/cache.js:1304:11)
at cb (/usr/local/lib/node_modules/npm/lib/cache.js:646:5)
at /usr/local/lib/node_modules/npm/lib/cache.js:655:20
at /usr/local/lib/node_modules/npm/lib/cache.js:1290:7
at /usr/local/lib/node_modules/npm/node_modules/lockfile/lockfile.js:167:38
at OpenReq.Req.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:144:5)
at OpenReq.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:64:22)
at Object.oncomplete (fs.js:107:15)
If I try to run it as sudo, it seems to get further and start installing some packages, but some new errors popup instead:
> chokidar#0.8.1 postinstall /Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/chokidar
> node setup-deps.js
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
node.js:811
var cwd = process.cwd();
^
Error: EACCES, permission denied
at Function.startup.resolveArgv0 (node.js:811:23)
at startup (node.js:58:13)
at node.js:902:3
npm ERR! error rolling back Error: ENOTEMPTY, rmdir '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/q'
npm ERR! error rolling back karma#0.10.9 { [Error: ENOTEMPTY, rmdir '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/q']
npm ERR! error rolling back errno: 53,
npm ERR! error rolling back code: 'ENOTEMPTY',
npm ERR! error rolling back path: '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/q' }
npm ERR! Error: ENOENT, chown '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/socket.io/lib/socket.io.js'
I recently updated my node and npm installations. So maybe that has something to do with it. Also, most of my development has been at the office and today I'm working over VPN, so maybe that has something to do with it too.
Any ideas?
As per photusenigma at: https://github.com/npm/npm/issues/4815
Run these commands in a terminal window (note - DON'T replace the $USER part...thats a linux command to get your user!):
sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/local/lib/node_modules
...and...if you're on a mac (like I am), and still see errors after running these commands, then run this last one and you should be good. (Recommend you try testing before you do this one. I don't like changing the permissions on the ENTIRE /usr/local directory unless it really seems necessary!)
sudo chown -R $USER /usr/local
I worked with a co-worker this afternoon and figured out what the problem was. My ".npm" folder in my home directory was owned by the root user instead of myself. I'm not sure what happened to cause that. Maybe I installed node or npm as the root admin at one point. In any case I just ran sudo chown -R [username] .npm and I was finally able to run npm install commands from my projects again!
In my case the issue was invoking npm with a user that does not have a HOME directory, so for example the following command would fail:
sudo -u someUser npm install
The solution is to provide a HOME directory, where someUser has write access:
sudo -u someUser HOME=/some/directory npm install
Had the same issue and fixed it by changing the persmissions as per the accepted answer:
sudo chown -R $USER ~/.npm
However, the second command should be avoided as it downgrades the permissions of a system resource (sudo chown -R $USER /usr/local/lib/node_modules). Not a good idea.
For the record: "usr" in /usr/local stands for Unix System Resources.
None of this worked for me. I had to run literally as root by doing the following:
sudo su -
sudo npm install forever -g
Then the package installed on Linux Ubuntu 14.04.
The following command should fix permission issues:
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
You can read about another officially recommended solutions here:
https://docs.npmjs.com/getting-started/fixing-npm-permissions
My solution:
sudo chown -R $USER /usr/local/lib/node_modules/NAMEOFMODULE
in my case was :
sudo chown -R $USER /usr/local/lib/node_modules/appium/
But I was getting the same problem, finally after
npm cache clean
it worked !
I had the same problem and tried to fix the permission/ownership of npm related files and directories for hours but had no luck with that.
Suddenly I found that I had ~/.npmrc file with cache entry pointing to a non-existing directory. Removed that cache property to use the default cache location and now it's solved.
Disclaimer
I am a Windows user. However, my team and I have come across a number of issues regarding npm installaion errors.
Problems
The following is a list of lessons learned and a possible radical solution that has always rescued us:
node_modules, the npm local installation directory becomes protected from modification by a shortcoming of the OS such as the inability to process paths longer than 255 characters.
If the folder is erased by means of a command line tool it may still appear as if the folder exists in the explorer that when trying to access it gives a number of permission errors.
Depending on your antivirus and/or local policy manager you may be able to create the node_modules folder and later relegated access or permissions to it resulting in a number of installation errors.
Enable npm logs to gain further insight into possible problems with:
npm install --loglevel verbose
Radical
Install rimraf globally
npm install rimraf -g
Run rimraf on node_modules:
rimraf yourDir/node_modules
Then try running:
npm install
Warning!
Or lack there of. Be extremely careful about what follows the command rimraf. There are no warnings, no prompts, there is nothing. It simply erases the directory from the phase of the earth clean, as if it was never there. Try it at your own risk.
for me, it was my proxy... and make sure to delete package-lock.json.
this worked for me on my mac / unix based system:
npm config rm proxy
npm config rm https-proxy
npm config delete proxy
npm config delete https-proxy
npm config --global rm proxy
npm config --global rm https-proxy
npm config set registry "http://registry.npmjs.org"
npm config set strict-ssl false
npm install
run: scutil --proxy
you should get dictionary list...
then get these values from that list:
HTTPProxy : 127.0.0.1 HTTPPort : 8118
then include them in this command:
npm config set proxy http://127.0.0.1:8119
then include this:
npm config set https-proxy https://123.0.0.1:8118
reference: https://www.sneppets.com/angular/how-to-make-npm-install-command-to-work-behind-proxy/

Resources