ggascoigne / prettier-plugin-import-sort

Prettier plugin to pass javascript and typescript through import-sort
MIT License
110 stars 11 forks source link

Error: prettier-plugin-import-sort: Style "module" could not be resolved #6

Closed denizdogan closed 4 years ago

denizdogan commented 4 years ago

I recently started getting this whenever I try to use Prettier on my code. I'm not sure what I've changed that causes it to happen.

Error: prettier-plugin-import-sort:  Style "module" could not be resolved
    at throwIf (/[...]/node_modules/prettier-plugin-import-sort/src/index.js:19:11)
    at getAndCheckConfig (/[...]/node_modules/prettier-plugin-import-sort/src/index.js:36:3)
    at organizeImports (/[...]/node_modules/prettier-plugin-import-sort/src/index.js:46:18)
    at Object.preprocess (/[...]/node_modules/prettier-plugin-import-sort/src/index.js:65:14)
    at Object.parse (/[...]/node_modules/prettier/index.js:9734:21)
    at coreFormat (/[...]/node_modules/prettier/index.js:13252:23)
    at format (/[...]/node_modules/prettier/index.js:13510:73)
    at formatWithCursor (/[...]/node_modules/prettier/index.js:13526:12)
    at /[...]/node_modules/prettier/index.js:44207:15
    at Object.format (/[...]/node_modules/prettier/index.js:44226:12)
Process finished with exit code -1

The file I'm trying to format looks like this:

const Dot = () => {
    const classes = useStyles();
        return (<div className={classes.dot}>
        foo
    </div>);
};

(I removed all other code because it's not open source, Prettier should be able to format it either way, right? I can't share the full code, unfortunately.)

My package.json has:

  "importSort": {
    ".js, .jsx, .ts, .tsx": {
      "style": "module",
      "parser": "typescript"
    }
  },

When I remove "style": "module", I get this error instead:

Error: prettier-plugin-import-sort:  Style "eslint" could not be resolved

The file I'm trying to format is TypeScript with JSX. I bundle my code using Parcel and minimal configuration of it that has been working up until now.

I'd appreciate any help on this one! 👍

ggascoigne commented 4 years ago

Do you still have import-sort-style-module in your dependency list?

ggascoigne commented 4 years ago

closing this due to lack of activity.

denizdogan commented 4 years ago

Sorry, I forgot to follow up! But the issue is not relevant for me anymore, thanks for taking the time!

RobertGardner commented 3 years ago

Since I see some people gave a thumbs down to closing this bug...

I had exactly the same problem, same error. After some investigation, I discovered that, as @ggascoigne suggested, I had accidentally removed import-sort-style-module from my devDependencies. Reinstalling it fixed the problem.