Prettier doesn't work in IDEA 2019.2

Hello. I have some problems with prettier in my IDEA. Watch mode doesn't work for me. I use this instruction https://prettier.io/docs/en/webstorm.html and it doesn't work in watch mode. When I keypress Ctrl + S happens anything. 

Moreover, hotkeys CTRL+ SHIPT+ALT+P doesn't work also. Although, I cheked it in hotkeys and it hotkey there are.

   

Sometimes I can see next error

```

/assets/node_modules/.bin/prettier --write assets/src/pages/HomePage.js
/usr/bin/env: ‘node’: No such file or directory

Process finished with exit code 127

```

And I set all necessary settings for prettier and node. I use nvm LTS node 10.16.3.

I have this problem with prettier on two my computers. And OS Ubuntu 18.04.3

Can we help me?

11 comments
Comment actions Permalink

>/usr/bin/env: ‘node’: No such file or directory

 

Looks like node is not on your $PATH. Does the issue persist if your start IDEA from terminal, either with the command line launcher or with bin/idea.sh?
When being launched from desktop/System menu, IDEA only sees environment variables configured in login shell, but not in interactive shell configuration files (like .bashrc or .zshrc).
Possible workarounds:
- Workaround 1: make required variables available in a login shell by moving them to the corresponding shell profile config
- Workaround 2: run IDE from a terminal
- Workaround 3: edit the desktop launcher and set command to /path/to/shell -l -i -c "/path/to/idea.sh" (make sure that the shell you specified there has the needed variables configured in its interactive shell configuration file)

see also https://youtrack.jetbrains.com/issue/IDEABKL-7589

0
Comment actions Permalink

Thanks, if I run IDE from a terminal prettier works on ctrl + s, but it doesn't work Ctrl + Shift + Alt + P also. 

And I install snap package from ubuntu software.

0
Comment actions Permalink

>it doesn't work Ctrl + Shift + Alt + P also

 

Does it work if you choose Reformat with Prettier action from the file right-click menu using mouse (i.e. when not using shortcuts)?

If it doesn't, please share your idea.log (Help | Show Log in ...)

Note: please don't paste log content here, upload it to some file server and provide a link

0
Comment actions Permalink

No, it works when I use right menu. Do you need idea.log yet?

0
Comment actions Permalink

No; did you try assigning a different shortcut to this action? What system keyboard layout do you use?

0
Comment actions Permalink

It looks like this is a common issue when installing using Software Manager in distros such as Ubuntu or Mint. Had the same problem a couple of days ago.

0
Comment actions Permalink

I have the same problem with a hotkey - it doesn't work. Reassigned hotkey doesn't work either. Even more, there is no action "Reformat with Prettier" in Find action dialog, nor in the context menu. While reformating on save works well.
OS: Windows 10 x64
IDE version: 2019.2.1
IDE installation type: not clean, updating from previous versions.

0
Comment actions Permalink

Is Prettier plugin installed and enabled (check Settings | Plugins)? If yes, did you specify Prettier package in Settings | Languages & Frameworks | JavaScript | Prettier?

0
Comment actions Permalink

Sure, installed, reformatting works on save.
I didn't specify Prettier in Settings | Languages & Frameworks | JavaScript | Prettier.

Thanks! Specifying this solves the problem.

Shall we do it manually or WebStorm must do it? Asking, because there is nothing about it in Prettier docs.

0
Comment actions Permalink

>Sure, installed, reformatting works on save.

You must have it set up as a file watcher, it has nothing to do with the IDE Prettier plugin

>Shall we do it manually or WebStorm must do it?

You have to do it manually; see https://www.jetbrains.com/help/webstorm/2019.2/prettier.html#ws_prettier_configure

0
Comment actions Permalink

Thanks, Elena.

Needs to post an issue in Prettier.
Also, the plugin's page could have this info as well.

0

Please sign in to leave a comment.