-
-
Notifications
You must be signed in to change notification settings - Fork 750
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
Extra logging for when installed npm is not active after install, or extra test in doctor #762
Comments
I suspect you had npm installed in a custom location, separate from where node was installed. I see What does (A custom prefix might be set in your |
➜ npm prefix -g
/Users/phil/.npm
┌─────────────────────────────────────────────────────────┐
│ 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/phil/.config │
└─────────────────────────────────────────────────────────┘ |
I reproduced the issue by setting the npm prefix, installing an npm there, and modifying my PATH to have that first. The underlying problem is that the freshly installed version of npm is not the first found in the PATH. The existing logging omits the npm information in this case, so at least accurate as far as it goes! 😄 The extra logging for when this happens with node is at:
The test in The multiple versions in PATH could also happen with other installed binaries like (A small subset of users may deliberately install npm global modules to a custom directory so they can manage it independently of node.) |
Thanks for the detailed description, including looking to |
What do you think about the suggested additional hints? |
If you are asking about the specific hints, neither of the suggested hints are quite what I would want.
The problem isn't that it is installed globally as such, the problem is that it is installed somewhere different to the location There is an additional factor in this particular issue that a custom global prefix has been set. That is going to affect future npm installs. But it is the expected behaviour the user has opted into (a bit like the following).
The user has set the environment variable, so I don't think If you are asking what I thought about having additional information about npm issues with the install, I am still thinking about that. It has not come up a lot (or at least not compared with multiple node versions!) But having some clues so new users can hopefully diagnose setup issues is good, if it does not introduce too much noise for "normal" scenarios. A fallback is extending the |
I didn’t mean the specific hint I suggested. These were just examples. I wasn’t even aware that Didn’t change the npm version. Run What do you think? |
Possible, yes. I did actually have something similar in an early version of the extra messages for a shadowed node install with I went with just the installed/active lines, but people don't always work out what it means. |
Opened a PR adding a check to |
Added npm check to Thanks @googol7 |
Short Version
When I ran
n
it didn’t install the bundlednpm
version. I had to uninstall the globally installednpm
. Now it works.Long Version
When I switched the Node version with
n
I just saw:I expected to see:
I didn’t preserve the
npm
version.n doctor
didn’t tell me why.Solution
I uninstalled the globally installed
npm
to letn
also switch to the bundlednpm
version:npm uninstall -g npm
Feature request
n
should be a little bit more verbose and tell us why it doesn’t also switch the bundlednpm
version. The message could be:The hint could also be:
hint : Didn’t switch the bundled
npm
version because the environment variableN_PRESERVE_NPM
is set.References
Configuration Details
The text was updated successfully, but these errors were encountered: