Gudahtt / prettier-plugin-sort-json

A plugin for Prettier that sorts JSON files by property name.
MIT License
103 stars 12 forks source link

Cannot find module 'prettier/parser-babel' #185

Closed mauriau closed 1 year ago

mauriau commented 1 year ago

I don't know exactly why this happens, but when running prettier I have this error

yarn run v1.22.19
warning package.json: No license field
$ npx prettier --no-error-on-unmatched-pattern --write .
[error] Cannot find module 'prettier/plugins/babel'
[error] Require stack:
[error] - /usr/src/project/node_modules/prettier-plugin-sort-json/dist/index.js
[error] - /usr/src/project/node_modules/prettier/index.js
[error] - /usr/src/project/node_modules/prettier/cli.js
[error] - /usr/src/project/node_modules/prettier/bin-prettier.js

I had this into my prettierrc

{
    "tabWidth": 4,
    "useTabs": false,
    "semi": false,
    "singleQuote": true,
    "trailingComma": "es5",
    "endOfLine": "auto",
    "arrowParens": "always",
    "plugins": ["prettier-plugin-sort-json"],
    "jsonRecursiveSort": true,
    "overrides": [
        {
            "files": ".prettierrc",
            "options": { "parser": "json" }
        },
        {
            "files": ["assets/js/**/*.js"],
            "options": { "parser": "flow" }
        },
        {
            "files": ["assets/js/**/*.{ts,tsx}"],
            "options": { "parser": "typescript" }
        },
        {
            "files": ["src/**/*.{yml,yaml}"],
            "options": { "parser": "yaml" }
        },
        {
            "files": ["**/*.{json}"],
            "options": { "parser": "json" }
        },
        {
            "files": ["translations/*.{json}"],
            "options": { "parser": "json" }
        }
    ]
}

Does I have to change something ?

mauriau commented 1 year ago

It's fine. I was in prettier 2.8 not 3.0 to use your plugin in 3.0