Reputation: 357
I am using ubuntu 15.04.
I recently installed nodejs through this ppa https://deb.nodesource.com/node_0.12
using the instructions found here:
https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories
npm came installed as part of the node install from this ppa.
i am assuming simply running apt-get update and upgrade will keep my nodejs at the latest version. My question is, will it also keep npm at the latest version???
OR
Will i have to manually keep npm updated using:
npm install npm -g
As described here: https://docs.npmjs.com/getting-started/installing-node
I am cautious about this, as after installing npm, i changed my global npm package install location to a directory in my home folder as per this: https://docs.npmjs.com/getting-started/fixing-npm-permissions
to avoid npm permission problems with global packages.
So my global package install location is now: ~/npm-global
instead of usr
My worried brain is telling me that running that command may install a second version of npm in my home folder global npm install directory. Instead of updating the original install which was installed along with node from the ppa. This is located in usr
I am presuming, since that is the original global packages location.
Thanks for any advice you can offer about the correct way to keep node and npm updated to the latest versions.
I hope my question was clear, feel free to ask for more clarification. Thanks!
I also must ask, would it have been advisable to have left the global install location as is, and instead just use sudo
when installing global npm packages??
The tutorial I linked seemed to imply creating a global npm packages folder in your home directory was more sensible than using sudo
?
Upvotes: 2
Views: 2496
Reputation: 361
use nvm
as described by this answer.
https://askubuntu.com/a/605813/107509
I tried to avoid this solution as first, but nodejs is now very hard to install, and most of the simple curl
solutions I've seen don't work for me.
Upvotes: 0
Reputation: 9727
Using NodeSource PPA will help you to keep node updated with apt
, npm
will be updated to the latest version bundled in the Node.js version you have installed.
If you don't want to override npm upgrade with your setup I would recommend to put the ~/npm-global/bin
folder before the /usr/bin
.
Another approach is to use a version manager like nvm or n to manage multiple Node.js (or io.js) versions, personally this is the approach I use and you don't need to use sudo
while installing packages, everything (even node) will be installed in your home folder.
Upvotes: 2