I'm trying to run npm
in an ant task that I run from within Eclipse, but it fails.
Cannot run program "npm": error=2, No such file or directory
My terminal and system path can run npm,
fine, and I've tried various solutions suggesting how to ensure an app started with Finder can use the system path, but none of them helped.
What's the way to solve this problem? I'm using Mac OSX El Capitan, and using zsh. In the past, I had symlinked npm to /usr/bin
, but that's not allowed on El Capitan.
I've got 3 working solutions right now,
1) So far, my best solution is to launch Eclipse using an alternate application launcher you can easily create using Apple Script.
Create an Apple Script like by Running "Script Editor", clicking "New Document", and supplying the following:
tell application "Terminal"
do script "open -a Eclipse.app; exit"
delay 5
quit
end tell
Export that as an application, by
EclipseLauncher.app
, and I saved it under Applications
Run that instead of Eclipse.app
.
Note: If you have Eclipse running, you have to shut it down before trying this out.
2) Start Eclipse from the terminal - it will pick up the system PATH
defined there, and find npm when I try and run an ant task.
$ open /Applications/Eclipse.app
3) Change how Eclipse launches the ant task:
Ant view
in Eclipse.npm
, e.g. /usr/bin/:/usr/local/bin
, or if you're on Windows, probably add this to your PATH, C:\Program Files\nodejs
. Windows users may be able to solve this globally by ensuring npm is in your system Windows pathNote that you can find the path to npm in your terminal by running the following:
$ dirname $(which npm)