I have ran into the problem recently. We have a complex build process, including npm install task at my current project. The project hierarchy and build is handled by maven.
The problem is that when I run the build from the IntelliJ IDEA, it fails with the following error message:
An Ant BuildException has occured: Execute failed: java.io.IOException: Cannot run program "npm": error=2, No such file or directory -> [Help 1]
This error message apparently states, that there are no executable found. Hence, the $PATH is incorrect.
I've found the solution :)
First: make sure that
/usr/local/bin is in the $PATH variable!
Second: have a look at this answer at apple.stackexchange.com and create the
idea.sh file following the example.
Simply follow this two steps FTW!
P.S. Also, see this for additional insight: http://apple.stackexchange.com/a/57402
Have a nice NodeJS hacking!