5

I'm getting the following error when trying to JsPrettier my js and jsx code.

Prettier reported the following error(s):

[warn] Ignored unknown option --html-whitespace-sensitivity=css. [error] Error: Couldn't resolve parser "babel"

I've reinstalled both plugins now and am still getting the same error. Currently working in a project with create-react-app.

JsPrettier version 1.24.0 Sublime version 3.1.1

These are my Babel settings:

  "debug": false,
  "use_local_babel": true,
  "node_modules": {
    "windows": "C:/Program Files/nodejs/node_modules",
    "linux": "/usr/lib/node_modules",
    "osx": "/usr/local/lib/node_modules"
  },
  "options": {}
}

Is there a way to point JsPrettier to Babel? I'm not sure how exactly Sublime, Babel and Prettier all interact with each other. I'm guessing its just a matter of telling JsPrettier where the babel parser is?

Thanks in advance!

  • 1
    I have this same issue. I dont see a node_modules in that path listed in my babel settings though. Did you recently update npm? I'm wondering if the modules have moved – Abby Jan 30 '19 at 21:00
  • If I set the syntax of a file to plaintext then try autosave, prettier works correctly. Does it do the same for you? – Abby Jan 30 '19 at 21:09
6

Note: If you want to use the local install of prettier in your project, omit the -g from all commands

First, update your global version of prettier: npm update -g prettier

npm list -g prettier now gives me prettier@1.16.2

Now update your JsPrettier User settings (Sublime Text > Preferences > Package Settings > JsPrettier > Settings - User) and set the "prettier_cli_path" to point at your global bin

// JsPrettier.sublime-settings
{
...
  "prettier_cli_path": "/Users/abby/.nvm/versions/node/v10.14.1/bin/prettier",
...
}

(Check what the correct path is by running npm root -g and update it to the prettier bin)

| improve this answer | |
  • Thank you Abby! Worked perfectly! I switched to yarn and that was the issue. – Taylor N Jan 31 '19 at 15:12
1

FYI: Similar error in a slightly different setting.

------------------
JsPrettier ERROR 
------------------

Prettier reported the following error(s):

[error] Error: Couldn't resolve parser "babel"

Process finished with exit code 1

I have the prettier package installed locally also in our project, as specified in the package.json file.

I found it's of a quite old version. So I updated it and then error is gone.

$ yarn remove prettier
$ yarn add prettier -D
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.