how to update npm on macOS

Perhaps you have already solved this, but here is what I found when I had exactly this issue. I had 2 versions of npm installed.

I verified this as follows:

grep \"version\" ~/.npm-packages/lib/node_modules/npm/package.json

  "version": "6.2.0"

grep \"version\" /usr/local/lib/node_modules/npm/package.json

  "version": "5.6.0",

I worked around the issue by updating the path in my bash profile, but would like to know why (how) I ended up with 2 versions. Here is the update:

tail -2 ~/.bash_profile

NPM_PACKAGES="${HOME}/.npm-packages"

PATH="$NPM_PACKAGES/bin:$PATH"

Leave a Comment