Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm comes with node now. What does this mean?

Tags:

Node noob here.

I had previously installed both npm and node separately.

Apparently, npm comes with node now. (link)

To my newbie mind, this means my previous dual installation is old and ugly. 1 binary > 2 binaries. So i uninstalled both.

Then I installed the latest node following the procedure. (i am running eOS)

Terminal

user@box:-$ which node /usr/bin/node user@box:-$ node -v v0.10.22 user@box:-$ which npm user@box:-$ npm -v bash: /usr/bin/npm: No such file or directory 

I can always run:

curl https://npmjs.org/install.sh | sh 

but that seems to indicate that npm is actually NOT included in node.

When they say they are included do they just mean the code is in the same repo, but the binaries are still different?

Final question I have /usr/bin/node as well as /usr/bin/nodejs can i delete one of these? im not sure when/where i picked up a second copy.

like image 471
nograde Avatar asked Nov 21 '13 18:11

nograde


2 Answers

  • Yes, the nodejs package includes both node and npm executables. The code for each has its own repo, but when packaged both are included.
  • npm source: https://github.com/isaacs/npm
  • node source: https://github.com/joyent/node
  • When you install that .deb file from the PPA, you should get both /usr/bin/nodejs and /usr/bin/npm and 2 symlinks at /usr/bin/node (which points to) /etc/alternatives/node (which points to /usr/bin/nodejs).
    • If any of this isn't true, your install didn't fully succeed, most likely due to conflicting files you left around from your manual install. I would suggest uninstalling the .deb then making sure there are no stale files left from your manual install and then installing again.
like image 200
Peter Lyons Avatar answered Oct 14 '22 13:10

Peter Lyons


Only node.js packages comes with npm. so if you are installing using an .msi, .exe, .dmg .pkg, .deb or using a package installer like apt-get, yum or brew, then you'll have both node and npm.

However,npm is not part of the node core. if you are installing node and using a method where you are using ./configure or make install || make link, then npm will not be installed, and will need to be compiled using the same type of installation, and node will have to be placed on your path.

If you used git, or unzipped node and you can see a configure script, then you will also need to acquire npm.

like image 39
Brian Vanderbusch Avatar answered Oct 14 '22 15:10

Brian Vanderbusch