6

I am using Intellij ultimate 2017.3 and installed nodejs plugin on it. My nodejs project requires babel to do the translation work from es5 to es6. In order to make Intellij to be able to debug my nodejs process, I added a file watcher plugin to listen on the source code changes. Once a file is changed, it will run below command to translate the code:

babel ./src --out-dir ./lib --source-maps

this command works fine from my OS but I get below error in Intellij:

env: node: No such file or directory

Process finished with exit code 127

I am using MacOS 10.13.1 and my node is managed by nvm which is at the v8.9.1. Babel is 6.26.0. Is there any problem in Intellij to call babel command? Or is it a babel or node environment problem on my OS?

Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523

4 Answers4

15

It is a $PATH issue. You can set $PATH variable when configure file watcher.

  1. type in to your terminal echo $PATH
  2. copy result, it should be something like this /Applications/bin:/usr/local/bin
  3. Go to Preferences/Tools/File Watchers
  4. Select your file watcher, press enter or click "edit"
  5. Click "Other Options" and "Environment variables"
  6. Click "+"
  7. Type "PATH" in "Name" column
  8. Paste copied text in "Value" column
  9. List item
  10. Press ok

enter image description here

Link to original solution

Arseniy-II
  • 8,323
  • 5
  • 24
  • 49
  • 1
    This fixes a bug I had with prettier in 2020 running in file watchers on OSX. I wonder why intellij has the wrong PATH variable and if it is associated with the change to zsh – Quinma Apr 15 '20 at 16:31
  • I am running IntelliJ Ultimate. There is no entry 'File Watchers'. – Dirk Schumacher May 17 '22 at 05:14
4

Must be a $PATH issue. Can you check if the problem persist when running IDEA from terminal (open -a /Applications/idea.app )?

on MacOSX the environment variables differ between GUI applications and within the terminal. Terminal environment is only available to applications started from terminal. To solve this problem, IDEA tries to load terminal environment by executing the following command on startup:

<your shell> -l -i -c '/Applications/idea.app/bin/printenv.py'

Seems this command can't retrieve all needed stuff in your case - thus the issue.

Some links you may find useful: http://apple.stackexchange.com/questions/106355/setting-the-system-wide-path-environment-variable-in-mavericks, https://devnet.jetbrains.com/docs/DOC-1160#comment-2801, http://apple.stackexchange.com/questions/51677/how-to-set-path-for-finder-launched-applications.. The problem is that the way to define system-wide environment variables on Mac changes from one version to another (even minor system updates may break your environment)

lena
  • 90,154
  • 11
  • 145
  • 150
1

I had the problem with IntelliJ in combination with nvm. The problem is that FileWatcher doesn't seem to use bash. My solution was to add the following lines to the end of ~/.profile:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
Andreas Berger
  • 843
  • 6
  • 11
0

In my case with a similar issue, I had installed nvm and node. I only needed to reboot my computer for the changes to PATH to be reflected in the X environment.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268