Error: Cannot find module 'prettier/parser-babel'

See original GitHub issue

I don’t know exactly why this happens, but when running prettier via eslint --fix I got this error.

the error is trown by prettier-plugin-import-sort/src/index.js line

const { parsers: javascriptParsers } = _interopDefault(
  require('prettier/parser-babel')
)

even I’m using TS

below is my conf on package.json

  "importSort": {
    ".ts, .tsx": {
      "style": "renke",
      "parser": "typescript"
    }
  },

and my lint-staged config which is firing the eslint --fix

  "lint-staged": {
    "*.{js,ts,tsx,jsx}": [
      "eslint --fix"
    ]
  },

EDIT: Even if I run $(npm bin)/prettier manually, the same error happens

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
malthejorgensencommented, Mar 23, 2021

@c10b10 Had the same issue just now. The mistake was that I hadn’t used the right format for the importSort config in package.json. It doesn’t tell you if it’s malformed and then falls back to node_modules/eslint/lib/api.js as the style, which doesn’t work.

Not working

// package.json
"importSort": {
  "*.js": {
    "style": "module",
  }
},

Working

// package.json
"importSort": {
  ".js": {
    "style": "module",
  }
},
2reactions
kevinfarrugiacommented, Jul 16, 2020

I have received the same error and it was resolved by updating to prettier: ^2.x.x (previously was on prettier 1.x.x).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module 'prettier' - node.js - Stack Overflow
Prettier is a peer dependency of @vue/eslint-config-prettier so you need to add it to your own dependencies:
Read more >
Cannot find module 'prettier' error | bobbyhadz
To solve the error "Cannot find module 'prettier'", make sure to install the prettier package by opening your terminal in your project's root...
Read more >
babel-prettier-parser - npm
Prettier parser that allows for parsing of experimental syntax transformed by Babel. Latest version: 0.10.8, last published: 7 months ago.
Read more >
Cannot find module 'prettier' error [Solved] - Reactgo
The “Cannot find module 'prettier'” error occurs due to one of the following reasons: The module is not installed in the correct project…...
Read more >
Plugins - Prettier
When plugins cannot be found automatically, you can load them with: ... location of global npm modules, or any arbitrary directory that contains...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found