npm/npm

npm 1.4.14 doesn't honour prefix configuration (breaks "user global" installing)

thomastoye opened this issue ยท 9 comments

I ran into some trouble today after updating node and npm. Basically, npm wouldn't install packages globally to my prefix (~/.global_npm), it would try to install them to /usr/lib/:
newestnpmdoesntwork
The full npm debug log is here: https://gist.github.com/doublet/786fa01ed3adc20a3f9d

As a test, I downgraded to 1.4.10. It worked there:
npm1410works

I tested out several npm version, hopefully that will help you to it down:

npm -v Prefix is honoured (npm install -g works as expected)
1.4.0 Yes
1.4.5 Yes
1.4.10 Yes
1.4.11 No
1.4.12 No
1.4.13 No
1.4.14 No

I've run into the same issue, hope this gets fixed asap.
In the mean time, here are some workarounds (which perhaps may shed some light on what is going wrong):

To install a single package user-globally:

$ npm install -g --prefix=$(npm config get prefix) <package>

To 'downgrade' to a working npm (assuming that <prefix>/bin is on the $PATH:

$ npm install -g --prefix=$(npm config get prefix) npm@1.4.10
$ hash -r # if using Bash, to update its path cache
$ npm --version # Confirm correct version is now active
1.4.10

(Don't forget to $ npm uninstall -g npm; hash -r when a fixed npm is shipped with the next update of Node.js!)

Possibly related: this file was removed in 1.4.11
https://github.com/npm/npm/blob/v1.4.10/lib/utils/find-prefix.js

Same here ๐Ÿ‘

Downgrading to 1.4.10 seems like the simplest way to go while there is no fix.

Looking into @doublet 's comment, I've found that this happened at or around this commit: 1707fce
(not git bisect ed, but it is probably very close).

#5378 is intended to address this, so keep an eye on it.

๐Ÿ‘

๐Ÿ‘ had this issue with 1.4.14...

fixed by installing http://nodejs.org/dist/v0.10.28/node-v0.10.28.tar.gz instead of 0.10.29

It still happen. npm 3.3.6, node 5.0.0

Same issue on npm 4.0.5, node v7.3.0