Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

`npm link` behaves differently when `prefix` is set by CLI vs. env var #4483

danielmoore opened this Issue Jan 14, 2014 · 2 comments


None yet
4 participants

I would think this:

dmoore@dmoor-mba-osx: /tmp/npm-prefix-test/test-pkg
733 $ npm link --prefix /tmp/npm-prefix-test/npm/
/tmp/npm-prefix-test/npm/lib/node_modules -> /tmp/npm-prefix-test/npm

Would be the same as this:

dmoore@dmoor-mba-osx: /tmp/npm-prefix-test/test-pkg
734 $ export npm_config_prefix=/tmp/npm-prefix-test/npm/
dmoore@dmoor-mba-osx: /tmp/npm-prefix-test/test-pkg
735 $ npm link
/tmp/npm-prefix-test/npm/lib/node_modules/test-pkg -> /private/tmp/npm-prefix-test/test-pkg

But only the latter version actually does what I want. Am I doing something wrong here?


smikes commented Dec 4, 2014

Is this still a problem for you?

prefix is a special config variable. It has different behavior when specified on the command line for non-global installs. To get the latter behavior without using environment variables, I believe

$ npm --prefix=/tmp/npm-prefix-test/npm --global link

will work.

We are trying to clean up older npm issues, so if we don't hear back from you within a week, we will close this issue. (Don't worry -- you can always come back again and open a new issue!)



othiym23 commented Dec 18, 2014

Closing as abandoned. FWIW, I too think this is a wart; having one config variable overloaded to mean different things when used in different contexts is confusing for a lot of people. It's what's documented, though, which means that any changes to this behavior need to happen slowly and deliberately.

@othiym23 othiym23 closed this Dec 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment