Bugzilla – Bug 1148400
npmjs: different versions used by normal and sudo users
Last modified: 2019-08-29 18:27:48 UTC
Step to reproduce: 1. Install npmjs: sudo zypper in npmjs (installed at /usr/) 2. Update npm with npm: sudo npm i -g npm (installed at /usr/local/) 3. Run: npm -v 3. Run: sudo npm -v Expected result: > npm -v 6.11.1 > sudo npm -v 6.11.1 Actual result: > npm -v 6.11.1 > sudo npm -v 6.9.0 It seems "sudo npm" always using the older version installed at "/usr/" rather than "/usr/local/". But "/usr/local/" should have a higher priority?
Security policy removes /usr/local from your PATH when you do `sudo`. See sudoers config file. So marking this as invalid. Also, you should never run npm as root in the first place. If you wish to install global commands, those should be added to your own prefix instead. Even doing things like, > npm config set prefix ~/.npm > export PATH=~/.npm/bin:$PATH > npm install -g npm Add that PATH export to your ~/.bashrc and you are done. https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92 Now if you wish to install npm global for all users like that, it's OK, but they can all do that themselves locally if they need.
Finally, it's `zypper install npm10` or `zypper install npm12`. Nothing provides npmjs. > sudo zypper se --provides npmjs Loading repository data... Reading installed packages... No matching items found.
I added this to wiki: https://en.opensuse.org/Node.js#Change_location_of_global_packages