env: node: No such file or directory when setting up External Tool

So I installed a tool globally via 'npm install beautify -g' The docs on the tool indicate a simple usage of 'beautify -o <output_file> <input_file>'

So I create an external tool whose PROGRAM is '/usr/local/bin/beautify' (I have confirmed this file exists, though it is a symlink to '/usr/local/lib/node_modules/beautify/bin/beautify.js') I have confirmed that from the Terminal I can type 'beautify' and Terminal finds it, and can confirm that '/usr/local/bin' is in my $PATH.

For PARAMETERS I've foregone using macros for the moment and just put: '-o ./sample/test.beautified.css ./sample/test.css' (I can confirm that from my project root, there IS a '/sample/test.css' file)

For WORKING DIRECTORY I used the macro: $ProjectFileDir$ which shows me as '/Users/<username>/Web/sites/<project_folder>'

However, when I right click a file in the PROJECT WINDOW and run the External tool on the file, my "RUN" window opens with an error:

'/usr/local/bin/beautify -o ./sample/test.beautified.css ./sample/test.css
env: node: No such file or directory

Process finished with exit code 127'

I took the first line and pasted it into a Terminal that was sitting at my project root and BOOM, the file was processed and it created the '/sample/test.beautified.css' file as expected. I can confirm that I setup my Node interpreter and enabled the Node.js Core Library as well. It shows me using 7.4.0 (which is correct), and shows 'beautify 0.0.8' installed and '0.0.8' as the latest.

Ideas?

0
11 comments

What if you use "/usr/local/lib/node_modules/beautify/bin/beautify.js" instead of "/usr/local/bin/beautify" there?

0
Avatar
Permanently deleted user

Hey Dmitry, thanks for responding. When updated, I get:

/usr/local/lib/node_modules/beautify/bin/beautify.js -o ./sample/test.beautified.css ./sample/test.css
env: node: No such file or directory

Process finished with exit code 127

 

I am using the macro $ProjectFileDir$ for the WORKING DIRECTORY. There is a folder called 'sample' and there is a file in it called 'test.css'

0

Seems Node.js is not found in your $PATH. Try starting PHPStorm from terminal - does the problem persist? What OS are you on? Did you use NVM to install Node?

0
Avatar
Permanently deleted user

My Path shows as: 

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

My which node command shows:

/usr/local/bin/node

So I think it's in the path. I am on OSX El Capitan, 10.11.6

I do not use NVM. The problem does persist if I launch PHPStorm via the terminal.

0

>The problem does persist if I launch PHPStorm via the terminal.

 

this is strange, to put it mildly... when started from terminal, it inherits terminal environment, so $PATH should be the same as in terminal.

BTW, does the same command (/usr/local/bin/beautify -o ./sample/test.beautified.css ./sample/test.css) work in your system terminal?

0

I have the similar problem running prettier on my Webstorm 6.0 on my Mac

In terminal I run 

which prettier

/usr/local/bin/prettier

which node

/usr/local/bin/node

And in Webstorm External Tools configuration I have

/usr/local/bin/prettier
--write $FilePathRelativeToProjectRoot$
$ProjectFileDir$

And I get the error when I try to run prettier

/usr/local/bin/prettier --write test.js
env: node: No such file or directory

Process finished with exit code 127



0

In my case was problem that I'm using zsh instead of bash and nvm.

Added:

export NVM_DIR="$HOME/.nvm"
. "/usr/local/opt/nvm/nvm.sh"

to

~/.bash_profile

Problem solved.

3
Avatar
Permanently deleted user

On Ubuntu 18.04:

If you start IntelliJ by clicking on the icon in the Dash that was automatically added by IntelliJ, you can change this icon's behaviour like this:

  • find that icon's desktop entry by running find / -name 'jetbrains-idea.desktop'. For me it was /usr/share/applications/jetbrains-idea.desktop (for all users) or ~/.local/share/jetbrains-idea.desktop (for current user only).
  • modify the Exec key in that file to look like this: Exec=/bin/bash -i -c '<path_to_idea_startup_script>' %f.

Now starting the application will run ~/.bashrc and therefore setup NVM.

7

@Artur Zubilewicz

Thanks!

Note that one might also find it in: ~/.local/share/applications

 

0

@...
Worked also for /bin/zsh

0

Please sign in to leave a comment.