1

I'm trying to install and use grunt.

I install using npm install grunt -g

it seems to install -

grunt@0.4.3 /Users/me/.node/lib/node_modules/grunt

when I open up a new tab in terminal and run grunt I get

 -bash: grunt: command not found

My path looks like this

$ echo $PATH
            /Users/me/.rbenv/shims:/Users/me/.rbenv/shims:/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin 

Any advice? This is killing me.


I've installed grunt-cli too, still not working -

 npm install grunt-cli -g

/Users/me/.node/bin/grunt -> /Users/me/.node/lib/node_modules/grunt-cli/bin/grunt

I open a new tab

-bash: grunt: command not found

I installed node using the node installer. I'm on OSX.

I've just added /.node/bin to my path, see below -

 echo $PATH
 /Users/me/.rbenv/shims:/Users/me/.rbenv/shims:/.node/bin:/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/.node/bin:/opt/X11/bin:/usr/local/git/bin

It's still not working.

Finnnn
  • 3,530
  • 6
  • 46
  • 69

4 Answers4

1

Your path don't contain ~/.node/bin where apparently your globally installed npm binaries are kept.

You need to fix that if you expect said binaries to be picked-up.

Either way, this points out that you missed a step in your node / npm installation. How did you installed node exactly?

I don't know what other people do, but I'm using node from homebrew, which should take care of that for you (I assume from the paths you list that you are on OSX).

Mangled Deutz
  • 11,384
  • 6
  • 39
  • 35
  • thanks for looking at this, still not working. Added some info to my answer. – Finnnn Mar 08 '14 at 11:04
  • What you added to your path is *wrong*. /.node/bin is not the same thing as ~/.node/bin - to clear the confusion: add /Users/me/.node/bin to your path. – Mangled Deutz Mar 08 '14 at 13:38
  • Works perfectly. Thanks v much. You have no idea how much this was frustrating me. I owe you a drink. – Finnnn Mar 08 '14 at 13:51
  • Happy it helped! I'm in for the drink :-) (@MangledDeutz) – Mangled Deutz Mar 08 '14 at 16:23
  • I'm leaving this here as a reference to anyone who may need it: http://stackoverflow.com/questions/18409707/what-is-path-on-the-mac-unix-system – Termato Feb 03 '16 at 19:50
0

try to install grunt globally

   $ sudo npm install grunt -G
vodolaz095
  • 6,680
  • 4
  • 27
  • 42
0

You may have Grunt 0.4.3 installed globally but nothing installed locally.

  1. Run $ grunt --version to find which version you are on. At this point you'll only be knowing that you do have Grunt installed in your system. But to run Grunt at the directory level (also known as "project level") you'll need to be specific - because not every project may require the Grunt version you have installed globally.

  2. Create a package.json file in the directory you mean to have your project on. Let's call it the project's root folder.

    {
        "name" : "MyProject",
        "version" : "0.1.0",
        "author" : "My name",
        "private" : true,
    
        "devDependencies" : {
            "grunt" : "~0.4.2"
        }
    }
    
  3. Navigate to the project's root folder and run $ npm install. The specified Grunt version will be installed as a dependency to the project.

  4. Smile, you have Grunt up and running! :)

Wallace Sidhrée
  • 11,221
  • 6
  • 47
  • 58
  • It will of course help to have a few more dependencies and setup a `Gruntfile.js` to see stuff happening, but the above is enough to get started. – Wallace Sidhrée Mar 08 '14 at 13:18
  • When I try to run grunt --version I get -bash: grunt: command not found – Finnnn Mar 08 '14 at 13:39
  • Right. Did you try installing `Grunt` globally with `sudo`? Did you try skipping to step 2 and further? – Wallace Sidhrée Mar 08 '14 at 13:41
  • This is really good, and it will be even better if you add 1. log in as root. 2. ln -s /usr/bin/nodejs /usr/bin/node for those who have errors such as "/usr/bin/env: node: No such file or directory" – Kim Stacks Sep 10 '14 at 21:07
0

Sometimes another version or just a wrong path is referenced in the npm config file instead of the installed version.

This may cause node/npm to misplace global modules.

To check and fix:

  1. In cmd line type: npm config list
    You should get a list of configuration values, one of them is prefix.
  2. Make sure the path in prefix is the same path (only without node.exe) as the actually installed node.exe path.
    (this path is listed further down as node bin location)
  3. If it's not, change it:

    • Either in the config file (in your user folder, named .npmrc)
    • Or, via cmd line: npm config set prefix "C:\Program Files\nodejs" (change path if needed)
  4. Reinstall the module/package you tried to install, don't forget -g for global.

lilotop
  • 527
  • 6
  • 12