The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
(pre) Release: 6.10.2-next.1
I haven’t been announcing prereleases, but this is a good one. It’s currently on the
next tag, slated to be pushed to
latest on Tuesday, July 23 (ie, 1 week from today).
tl;dr - Fixes several issues with the cache when npm is run as
sudo on Unix systems. This should address Let's get rid of root-owned files in the cache! fully, but I’d really love for some other folks to test it out before declaring victory.
To try it out, you can run:
npm install -g npm@next
If you need to run
sudo to install globally, make sure that you
sudo chown -R $USER ~/.npm after doing so. (And, hopefully, this will be the last time!)
2a78b96f8check test cache for root-owned files (@isaacs)
108646ebcrun sudo tests on Travis-CI (@isaacs)
cf984e946set --no-esm tap flag (@isaacs)
8e0a3100dadd script to run tests and leave fixtures for inspection and debugging (@isaacs)
25f4f73f6add a util for writing arbitrary files to cache This prevents metrics timing and debug logs from becoming root-owned. (@isaacs)
2c61ce65dinfer cache owner from parent dir in
235e5d6dfensure correct owner on cached all-packages metadata (@isaacs)
6.10.2-next.1 just went live, with updates to npm-lifecycle and node-gyp. Changelog additions:
051cf20#26 fix switches for alternative shells on Windows (@gucong3000)
3aaf954#25 set only one PATH env variable for child process on Windows (@zkochan)
ea18ed2#36 #11 #18 remove procInterrupt listener on SIGINT in procError (@mattshin)
5523951#29 #30 Use platform specific path casing if present (@mattezell)
When running as sudo (without the -H flag), the HOME environment variable is /var/root by default.
This is incorrect. Try running
sudo sh -c 'echo $HOME' to verify. Then compare to
sudo -H sh -c 'echo $HOME'
The problem you’ve been having is that $HOME is set to the user’s home directory and thus the user’s ~/.npm/cacache is used even if the user invokes npm with sudo. This is not because $HOME is
/var/root, it’s because sudo does not change
I didn’t read the rest of this commit so it’s possible that your wrong assessment here doesn’t affect the rest of your patch.
Huh. On my system this was pulling up HOME as /var/root when running under sudo. It might be a different config somewhere? I’ll dig in further.
In any event, reading perms based on the actual cache location is better than pulling them from some other place, which might not be where the cache actually lives.