Prettier-atom: ERROR prettier.resolveConfig.sync is not a function

Created on 15 Sep 2017  路  35Comments  路  Source: prettier/prettier-atom


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
  }
}
bug

Most helpful comment

Installing prettier dependency and __restarting Atom__ both worked for me too :

$ yarn add --dev prettier

If it still not works for you, you also can downgrade prettier-atom to 0.38.0 version using apm :

$ apm install [email protected]

Finish by relaunching your editor.

All 35 comments

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.

Yes upgrading to 1.7 fixed the issue, thanks :)

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

I was getting

cannot read property 'sync' of undefined

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

@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).

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?

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?

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

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

@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 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

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

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

cannot read property 'sync' of undefined

And cannot update prettier for now

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

I'm experiencing the same issue as @tleunen

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

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.

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

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

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

Hi,

I'm annoyed by Prettier 1.7.0 since it brings serious changes the way it formats JSX. On ternary expressions, the indentation is wrong, leading to issues with prettier-eslint which I use

see for instance https://github.com/prettier/prettier/issues/2823

Could you make prettier-atom backward compatibility with prettier 1.7 for some time ...? I know it sounds weird and I apologize for that. The other solution I have is to stick to prettier-atom v0.38.0, but I don't feel very confortable of not upgrading atom plugins.

Installing prettier dependency and __restarting Atom__ both worked for me too :

$ yarn add --dev prettier

If it still not works for you, you also can downgrade prettier-atom to 0.38.0 version using apm :

$ apm install [email protected]

Finish by relaunching your editor.

@lazamar Do you mean they have a work-around in prettier-eslint-cli for the issue I mentioned?

@vcarel I think this issue may be happening because of incompatibility between versions of prettier and prettier-eslint or prettier-eslint-cli.

Seems like the API of one of these modules changed and didn't allow interaction with older versions of the other modules.

Actually, forget what I said, the problem still persists here. I had disabled eslint integration with prettier and forgot about it. That's why I wasn't seeing the error anymore.

Using prettier 1.4.4 here as the newer versions have a number of bugs with styled-components. Please keep prettier-atom backwards compatible.

I will go ahead and make the commit on prettier-eslint tonight, I do apologize but this is actually a problem in the prettier-eslint package and not prettier-atom. I did write this package to be backwards compatible with 1.4 AFAIK

This should be fixed in 0.40.0, please upgrade your prettier-atom package and restart Atom (important!)

prettier-atom failed: Cannot read property 'sync' of undefined
prettier-atom - 0.40.0

prettier@^1.7.0:
  version "1.7.0"

Deleted node_modules, updated prettier-atom, restarted - still that error appers.

Steps that fixed the issue for me:

  1. Update version in package.json in project dependancies to:
    "prettier": "^1.7.0",
    "prettier-eslint": "8.1.1",
  1. Restart the atom

Things are working now for me now 馃帀

@nwaywood how got you the Prettier debug output at your first post?

@gmuc there is a prettier command called prettier: debug. You can execute it from the command prompt

I am having the same issues, here's the output of prettier: debug:

Atom version: 1.22.0
prettier-atom version: 0.40.0
prettier version: 1.8.1
prettier-eslint version: 8.2.1
prettier-atom configuration: {
  "formatOnSaveOptions": {
    "excludedGlobs": [
      "package.json"
    ],
    "showInStatusBar": true,
    "enabled": false,
    "respectEslintignore": true,
    "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": {
    "semi": false,
    "singleQuote": true,
    "trailingComma": "es5",
    "bracketSpacing": true,
    "useTabs": false,
    "jsxBracketSameLine": false,
    "printWidth": 80,
    "tabWidth": "auto",
    "parser": "babylon"
  },
  "useEslint": true,
  "useEditorConfig": true,
  "prettierEslintOptions": {
    "prettierLast": false
  }
}

For anyone coming here with this issue, what fixed it for me was also installing prettier-eslint.

Was this page helpful?
0 / 5 - 0 ratings