When I attempt to update npm to the latest version I am advised the package has updated but when I go to check it returns the same version before the update. There are no errors to advise there was an error during the update.
What I can tell you is I'm not very confident with the inner workings of NPM itself. I know enough to run it if npm itself is configured completely.
About two years ago I started running my code in a different directory, same user (single user device) because I kept running into access issues and having to sudo every time I wanted to install any dependency. I don't recall remapping anything in any $PATH
or any npm configurations.
What I have tried
hash -r
to clear terminal cacheianbuss @ Ians-MacBook-Air in ~ [10:23:44]
$ npm -v
6.10.0
# ianbuss @ Ians-MacBook-Air in ~ [10:23:49]
$ sudo npm install -g npm@latest
Password:
/Users/ianbuss/.npm-global/bin/npm -> /Users/ianbuss/.npm-global/lib/node_modules/npm/bin/npm-cli.js
/Users/ianbuss/.npm-global/bin/npx -> /Users/ianbuss/.npm-global/lib/node_modules/npm/bin/npx-cli.js
+ [email protected]
updated 1 package in 11.955s
# ianbuss @ Ians-MacBook-Air in ~ [10:29:29]
$ npm -v
6.10.0
After searching forever for resolution and trying to learn more about the PATH. I found this article very useful for resolving this issue. Specifically, STEP 3: https://medium.com/@jagatjyoti.1si13cs040/npm-g-install-npm-package-not-working-as-desired-why-why-why-19795abf0b59
First check to see where the NPM global save path is:
npm bin -g
#output most probably but even if not don't worry till now
/home/<user>/node_modules/.bin
Then adjust accordingly:
mkdir ~/.npm-global
npm config set prefix `~/.npm-global`
export PATH=~/.npm-global/bin:$PATH
source ~/.profile
npm install -g <npm_packages>