Install prettier executable

The emacs mode requires the prettier executable to be installed. The easiest way to install prettier for me was to install it with npm global:

npm install --global prettier

Install prettier-js-mode

prettier-js is no available via Melpa, so the setup is quiet easy:

  • Open your .spacemacs (with SPC f e d)
  • Search for dotspacemacs-additional-packages
  • add prettier-js to it

Example:

dotspacemacs-additional-packages '(simpleclip prettier-js)`

Configure on-save

Search for dotspacemacs/user-config and add these two lines to it:

  (add-hook 'js2-mode-hook 'prettier-js-mode)
  (add-hook 'web-mode-hook 'prettier-js-mode)

Done

Now you can just reload your .spacemacs (SPC f e R) or restart emacs and prettier is available.