Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"prettier errors: env: node: No such file or directory" #63

Open
hew-wolff opened this issue Mar 9, 2020 · 6 comments
Open

"prettier errors: env: node: No such file or directory" #63

hew-wolff opened this issue Mar 9, 2020 · 6 comments

Comments

@hew-wolff
Copy link

Running prettier-js gives the error above. I did some searching and reading, and found that the "env" error usually means something is missing from the Emacs exec-path, so I tried things like this in .emacs:

(add-to-list 'exec-path "/Users/hewwolff/.nvm/versions/node/v10.18.1/bin")

As far as I can tell, node and prettier are both available at that path, but I still get the error.

Environment:

$ prettier -v
1.19.1
$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 10.15.3 (19D76)
      Kernel Version: Darwin 19.3.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: Hew’s MacBook Pro
      User Name: Hew Wolff (hewwolff)
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 3 days 1:38

$ node -v
v10.18.1
@petsgre
Copy link

petsgre commented Jun 5, 2020

i get same error

@itzikBraun
Copy link

I found this issue in NVM repository. I tried sudo env node in the terminal and had the same error as I got in emacs, i.e env: node: No such file or directory.

I am not sure why emacs has the same behavior as running sudo, but it only happens when I start emacs from desktop. If I run emacs from command line (with or without GUI), prettierjs works as expected.

I hope it helps even if it doesn't solve the problem completely. Maybe a more in depth reading of that thread will lead you to the answer, I am satisfied with running it from command line.

@LionyxML
Copy link

I do have this problems with MacOS also.

It seems to be a broader issue then just prettier.

When I start Emacs from Applications or Spotlight, env outputs different then when loading from the terminal.

You can output your env in shell and then output the env from e-shell inside emacs. If they are different you have this "broader" problem.

When launching from command line, repeat this experiment and you'll see both will be the same values.

This guy here made a "fix" for MacOS. If you're not in MacOS, I am sure something can be done with xdg or the default X launcher:
https://gist.github.com/d12frosted/18ed4b3b5d5267428a0da16da6d016b4

@LionyxML
Copy link

Also this did not fixed for me.

I usually run:
$ Open /Application/Emacs.app

@ishambhandari
Copy link

Try copying your ~/.bashrc to ~/.bash_profile. And source ~/.bash_profile.

@LionyxML
Copy link

I found the solution to this problem by installing this beauty from MELPA: https://github.com/purcell/exec-path-from-shell

After install, justa add this anywhere in your .emacs file:
(exec-path-from-shell-initialize)

And that's it. Now your shell path is available to GUI MacOS fired from from Desktop Applications, allowing you to run prettier, node, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants