prettier-atom icon indicating copy to clipboard operation
prettier-atom copied to clipboard

ERROR prettier.resolveConfig.sync is not a function

Open nwaywood opened this issue 9 years ago • 35 comments

Since the last update 0.39.0 I am getting the following error when trying to format a file:

image

Prettier debug output:

Atom version: 1.20.0
prettier-atom version: 0.39.0
prettier version: 1.7.0
prettier-eslint version: 8.1.0
prettier-atom configuration: {
  "formatOnSaveOptions": {
    "enabled": true,
    "excludedGlobs": [
      "**/*.html"
    ],
    "respectEslintignore": true,
    "showInStatusBar": false,
    "javascriptScopes": [
      "source.js",
      "source.jsx",
      "source.js.jsx",
      "source.babel",
      "source.js-semantic",
      "text.html.basic",
      "text.html.vue"
    ],
    "typescriptScopes": [
      "source.ts",
      "source.tsx",
      "source.ts.tsx"
    ],
    "cssScopes": [
      "source.css",
      "source.less",
      "source.css.less",
      "source.scss",
      "source.css.scss"
    ],
    "jsonScopes": [
      "source.json"
    ],
    "graphQlScopes": [
      "source.graphql"
    ],
    "whitelistedGlobs": [],
    "isDisabledIfNotInPackageJson": false,
    "isDisabledIfNoConfigFile": false
  },
  "prettierOptions": {
    "parser": "flow",
    "semi": false,
    "singleQuote": false,
    "bracketSpacing": true,
    "useTabs": false,
    "jsxBracketSameLine": false,
    "printWidth": 80,
    "tabWidth": "auto",
    "trailingComma": "none"
  },
  "useEslint": true,
  "useEditorConfig": true,
  "prettierEslintOptions": {
    "prettierLast": false
  }
}

nwaywood avatar Sep 15 '17 05:09 nwaywood

Will make a hotfix for this if you have an old version of Prettier, but you can also upgrade Prettier to 1.7 and it should work.

robwise avatar Sep 15 '17 06:09 robwise

Yes upgrading to 1.7 fixed the issue, thanks :)

nwaywood avatar Sep 15 '17 06:09 nwaywood

@robwise How do you upgrade prettier inside the atom package?

ooflorent avatar Sep 15 '17 08:09 ooflorent

I was getting

cannot read property 'sync' of undefined

upgrading prettier in the project's devDependencies to 1.7.0 solved it.

ptomasroos avatar Sep 15 '17 11:09 ptomasroos

@robwise How do you upgrade prettier inside the atom package?

The prettier inside of the atom package is already updated. If you are seeing this error, it means you have a local version of prettier (or prettier-eslint or prettier-eslint-cli).

robwise avatar Sep 16 '17 00:09 robwise

Guys, it seems that this is coming out of prettier-eslint still. I can try and make a PR over at prettier-eslint to gracefully fallback, but is anyone still experiencing this issue or is unable to upgrade prettier?

robwise avatar Sep 16 '17 08:09 robwise

Greetings everyone. I have the same issue even after having updated both prettier and prettier-eslint to versions 1.7.0 and 8.1.0 respectively. Any other ideas?

codeM1K avatar Sep 16 '17 18:09 codeM1K

Restart atom? 1.7.0 has resolve.config.sync so you should be good to go unless it's picking up an old version somehow

robwise avatar Sep 17 '17 08:09 robwise

I did restart atom . Same problem..almost actually, now I'm getting cannot read property 'sync' of undefined. Where's that resolve.config.sync you're referring to? Thanks

codeM1K avatar Sep 17 '17 13:09 codeM1K

@anal0gK1d It's still picking up an old version of Prettier. What do you get when you run npx prettier -v from your project directory?

darahak avatar Sep 17 '17 15:09 darahak

@darahak you're right! npx prettier -v gives me the following:

"npx: installed 1 in 3.144s 'prefix' is not recognized as an internal or external command,operable program or batch file. 1.3.1"

whereas prettier -v gives me:

1.7.0

codeM1K avatar Sep 17 '17 16:09 codeM1K

@anal0gK1d Looks like you updated your global install instead of your project's. Is it okay now?

darahak avatar Sep 17 '17 20:09 darahak

Will this be hotfixed anyway ?
I'm getting the error:

cannot read property 'sync' of undefined

And cannot update prettier for now

misterbridge avatar Sep 18 '17 12:09 misterbridge

Same issue here with 0.39.0. I don't have prettier in my project. I only have it inside atom.

tleunen avatar Sep 18 '17 16:09 tleunen

I'm experiencing the same issue as @tleunen

carlosconnected avatar Sep 18 '17 17:09 carlosconnected

npm install prettier --save-dev in a project folder solved the issue.

BroFox86 avatar Sep 18 '17 20:09 BroFox86

Same issue here with 0.39.0. I don't have prettier in my project. I only have it inside atom.

The bundled version of prettier has resolveConfig.sync defined, so you might have some sort of weird caching problem. I would try uninstalling and reinstalling the package and restarting Atom and seeing if that fixes it.

Will this be hotfixed anyway ?

Since people are still having problems, I will try and make a PR over at prettier-eslint to make a conditional check instead of hard-erroring like this.

robwise avatar Sep 18 '17 21:09 robwise

thanks a lot @BroFox86 yarn add prettier -D indeed solved the issue!

carlosconnected avatar Sep 18 '17 22:09 carlosconnected

Adding prettier to my dev dependencies did nothing to resolve this issue for me. Any other ideas??

ffxsam avatar Sep 18 '17 23:09 ffxsam

@ffxsam In your case, I would also try to add prettier-eslint or/and prettier-eslint-cli mentioned by @robwise.

BroFox86 avatar Sep 18 '17 23:09 BroFox86