Using Brew I have installed Node 8.x due to a version restriction on something i am working on.

I used brew install node@8 in the command line

However i need npm 5.x for a similar reason, which I gather should be possible. However whatever or however Brew installed node/npm I can not override the npm version which is 6.x

Any ideas how I can get this to work?

I have also tried post install to do npm install -g npm@5 which installs a version of npm somewhere, but it is not overriding the npm installed through node@8

2 Answers 2


It seems that the symlink of the old npm version still exists.

  1. Install the npm version you want
npm install -g npm@X.X.X
  1. Remove the sym link in /usr/local/bin/
rm /usr/local/bin/npm
  1. Recreate the sym link for the correct version of npm
ln -s /usr/bin/npm@X.X.X /usr/local/bin/npm
  • I had actually ended up doing that myself and it worked as expected. So I am going to accept this as the choice answer. The alternative though if you want something less permanent is using nvm
    – chris
    Jun 12, 2019 at 20:38

Easier than messing up with Homebrew is to use asdf package manager. With that you can have multiple version of Node.js (as well as many other development tools) installed and configured running different versions in different directories. It looks like you can have it installed using Homebrew:

$ brew install asdf

Then you can install Node.js plugin using

$ asdf plugin-add nodejs

You can list versions of available Node.js versions by

$ asdf list-all nodejs

and choose the desirable versions to install, e.g.

$ asdf install nodejs 8.17.0
$ asdf install nodejs 14.4.0

You need to have asdf in your $PATH before anything else; I am not sure where these are if using Homebrew installed asdf, but Homebrew should tell you how to configure your shell profiles during installation.

You can activate a version of Node.js (and associated NPM) as a global default by

$ asdf global nodejs 14.4.0

or locally in the given directory (and subdirectories) with

$ asdf local nodejs 8.17.0

(which will just write .tools file in the directory specifying the desired version).

Each of the Node.js environment have their own global packets.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .