Brew - Node@8 with npm v5 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
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.