npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Offer update by current package manager

Currently when update is available it will print something like this:

   │                                                               │
   │       New minor version of npm available! 6.1.0 → 6.2.0       │
   │   Changelog:   │
   │               Run npm install -g npm to update!               │
   │                                                               │

The last sentence is problematic in case NPM is installed by some other package manager, e.g. homebrew.

It should recognize some common package managers, test if current NPM is installed by this manager and then offer command for this manager. So in my case it should print:
Run brew update npm to update!

I would love an RFC for this. We just need someone to take the time to research how to even detect this and be specific about the alternative installers we’re going to support. Would you be interested in that?

Just partly:

With brew you can test if it is installed by it:

brew ls --versions npm

It will print installed versions of package containing npm (usually node) or nothing if npm is not installed with brew.
If this command prints something you can safely run brew upgrade npm (it will do brew update if not already done today and upgrade node).

It just have one imperfection: NPM checks it’s new releases, but not if this new version has been released already in node package in brew repository. This will probably be and issue also with other package managers.

I know this is an error in Homebrew, not NPM per se, but I’m mentioning it here for reference.

Various solutions exist, YMMV. For me it was some combination of

brew upgrade node
brew unlink node
sudo chown -R alex /usr/local/lib
brew link --overwrite node