Question

searched, and did not see this specific problem.

Trying to get a MEAN stack built on my Linux Mint machine, and bumping into a bit of an unusual issue.

Got MongoDB installed, and finally got it running correctly (none of the instructions ANYWHERE mentioned having to create the /data/db/ directory and set permissions, go figure).... it works now.

Got NodeJS installed, and it appears to work correctly.

I had been told (apparently incorrectly) that NPM installs right alongside Node, with:

sudo apt-get install nodejs

but:

$ npm
bash: /usr/bin/npm: No such file or directory

So I go ahead and install NPM separately.

$ sudo apt-get install npm

Seems to work, so far, no errors, and it looks like it is pulling down the NPM package and installing it...

$ nodejs -v
v0.10.21
$ npm -v
$

?? It simply fails to respond without any error... so I try:

$ npm install grunt -g --save-dev
$

Same completely silent failure... in fact, NOTHING I could do gets a response out of NPM.

Looked all over the web, and saw nothing similar anywhere... found out that NPM holds its cache files in ~/.npm and noticed that this folder didn't exist (kinda like the mongo issue above), so I created it, and set permissions to 7777... still nothing.

Purged and re-installed both node and npm, tried installing them both together and separately (yes, desperation)... still no love.

WTF am I doing wrong?

I would love, eventually, to have a nice development environment setup, hopefully with Cloud9 as a local IDE.... but already pulling my hair out.

=========================================================================================

OK, after a few more headaches, this is up and built now... thank you all.

Would love to mark both as answers, but it won't let me.

Was it helpful?

Solution 3

I don't believe npm comes with the nodejs installation in the apt repo. Try to install npm separately using the following tutorial http://www.giantflyingsaucer.com/blog/?p=1688 'To install NPM ....'

====== Edit ====

node and npm IS separate. Follow the official wiki and everything should be fine

OTHER TIPS

npm does come with node. Where is apt-get pulling it from? I install the Mac OS X packages on my Mac for development and npm does in fact come with it. I compile from source on my CentOS server and npm comes with it.

Your package provider may be providing them separately as a (in)convenience to you.

As for why your npm command does not work after installation, I can't say for sure, but I am suspicious of your use of --save-dev and -g together.

-g means to install globally, which means 2 things:

  1. It will be installed outside of your npm package's structure into a system location like /usr/bin or /usr/local/bin
  2. It requires root access to install. Did you use sudo to run it with root access?

Both of those requirements conflict with --save-dev which records the package as a dependency in your package.json file so that future npm install commands will install that package within the project space.

That said, I happen to know a lot about grunt. It has 2 parts, a globally installed tool and the package-specific tool. The correct way to install it is:

$ [sudo] npm install -g grunt-cli
$ npm install grunt --save-dev

This will install the grunt-cli package into a system location guaranteed to be in the $PATH, which turns around and looks for a package-specific grunt installed which is not system-wide.

When installing nodejs with npm, this one-liner worked for me.

sudo apt-get install nodejs nodejs-dev npm

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top