I am trying to make Jsprettier work in Sublime, but the formats I set up can't be applied, because I keep getting an error when I want to save a document (jsprettier: format failed). When I open the console to see what the error is it says: The system cannot find the path specified. (CR).
The settings in the user settings tab of jsprettier are the following:
{
"prettier_cli_path": "/c/Users/Adri/AppData/Roaming/npm/prettier",
"node_path": "/c/Program Files/nodejs/node",
"auto_format_on_save": true,
"prettier_options": {
"printWidth": 120,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"parser": "flow",
"semi": true,
"tabs": false
}
}
Thank you
tested on: Sublime Text 3.2.2, MacBook Pro
npm install --global prettier
Sublime Text
-->Preferences
-->Package Control
-->type and enter: Install Package
-->type and enter: JsPrettier
In your terminal run the following:
which node
which prettier
Copy the result of the output for each step and in SublimeText3 proceed to:
Preferences
--> PackageSettings
--> JsPrettier
--> Settings-User
In the user settings build your file as such:
{
"prettier_cli_path": "output from terminal here",
"node_path": "output from terminal here",
"auto_format_on_save": true,
}
I found that when JsPrettier updates it erased these settings on me and needed to re-enter them...
Hope that helps.
In case this helps anyone:
While this installed easily on one computer, I struggled with it on a second one.
After being required to set the node and prettier_cli path, I got node errors.
What worked in the end was setting the prettier_cli_path to prettier.js within the prettier node_modules directory as such:
C:/Users/Me/AppData/Roaming/npm/node_modules/prettier/bin-prettier.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With