Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apparently $PREFIX used by npm #692

Closed
hutson opened this issue Mar 16, 2015 · 1 comment
Closed

Apparently $PREFIX used by npm #692

hutson opened this issue Mar 16, 2015 · 1 comment
Assignees

Comments

@hutson
Copy link

hutson commented Mar 16, 2015

I've just recently started using nvm to help facilitate testing npm packages against multiple versions of Node. I quickly ran into issues with updating my global install of npm, only to discover pretty quickly what was causing my problem, i.e. #606 helped. I followed the instructions in that issue so that I could bring my local environment inline with what seems like best practice.

Unfortunately I kept running into the same issue. npm install -g npm kept installing into my prefix directory, but calls to npm kept referencing the nvm-managed node directory.

Following some helpful hints provided in other issues I discovered that npm actually checks for, and uses, the PREFIX environmental variable.

For example I have the following in my profile script:

(~)-()--> cat .profile | grep PREFIX
export PREFIX="${HOME}/.local"

I use that environmental variable for convenience. Next, I query npm to get the prefix directory it's using for installing npm packages.

(~)-()--> npm config list -l -g | grep prefix
prefix = "/home/hutson/.local"

As you can see, it's using the value of my $PREFIX environmental variable.

So my assumption was that if I unset that variable npm would use the correct directory.

(~)-()--> unset PREFIX 

Which it turns out it did:

(~)-()--> npm config list -l -g | grep prefix
prefix = "/home/hutson/.local/var/nvm/versions/node/v0.12.0"

So technically there is a workaround, use another name for my PREFIX variable. However, before going down that path I wanted to see if maybe I was missing something in my environment, or if there was a way I could keep using PREFIX.

@ljharb
Copy link
Member

ljharb commented Mar 16, 2015

ah ha - no, you're correct. Using literally any of the npm path configuration options will conflict with nvm, which needs to retain control of those.

I'm going to close this as a duplicate of #606, but I've commented on there so that gets checked also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants