Prettier-vscode: eslintIntegration. Cannot read property 'sync' of undefined

Created on 4 Oct 2017  路  23Comments  路  Source: prettier/prettier-vscode

It's the first time I'm trying to set it up, so I might have skipped something obvious, but can't figure it out.

After CMD + Shift + P -> Format Document , it shows in the Output tab:

Cannot read property 'sync' of undefined
image

I just installed the extension today, version 0.24
Settings of the plugin:
{
"prettier.eslintIntegration": true
}

prettier 1.6.1
eslint 4.8.0 . (installed globally)

.eslintrc content is:

{
    "extends": [
        "plugin:react/recommended"
    ],
    "plugins": [ "react" ],
    "parserOptions": {
        "ecmaVersion": 8,
        "sourceType": "module",
        "ecmaFeatures": {
            "impliedStrict": true,
            "jsx": true
        }
    }
}

bug locked

Most helpful comment

npm update -D prettier

ctrl+shift+p -> Reload Window

This should work

All 23 comments

in package.json of the project we have "prettier-eslint": "^6.4.1", (although prettier is installed globally)

I also enabled VS Code DevTools, nothing there

Prettier 1.7.0 has the sync() function that is missing here (1.6.1)

https://github.com/prettier/prettier/commit/088aa71b07bc25bc3640b1e188ec906ef6d17b1b

What I read here is not missing sync function but missing member.
Could you find a stack trace?

https://github.com/prettier/prettier-eslint/releases/tag/v6.4.3

prettier-eslint bundles in prettier and 1.6.0 of prettier was added in 6.4.3. Upgrading prettier-eslint should fix the problem.

Sorry, forgot to mention. We don't use user's installed version.
https://github.com/prettier/prettier-vscode/blob/master/src/PrettierEditProvider.ts#L125

We bundle [email protected]

Ah, didn't know that. What are the possible ways it is resolving prettier <1.6?

It's the one installed locally. This is the case, but we use resolveConfig (async version) from our bundled prettier

In

Cannot read property 'sync' of undefined

It's not sync which makes me think of a problem, but undefined

The only .sync in our src is here: https://github.com/prettier/prettier-vscode/blob/master/src/requirePkg.ts#L14
This line shouldn't be hit with eslint.

Thanks for the help, I updated prettier globally to latest, didn't work
Then, update prettier-eslint, I got 6.4.3 version .. and after restarting VSCode it worked !
Thanks for the fast replies guys, appreciated!

So the _fix_ is "restart vscode" ?

Out of curiosity, have you restarted vscode in those last 2 days? (since you installed last release )

@CiGit the fix in my case was removing prettier from my node_modules, adjusting my package.json file to use the latest version of prettier (1.7.4) and hitting npm install. Ofcourse restart vscode after 馃憤

So [email protected] + eslintIntegration fails?

Just tried and it works on my machine :-)

What doesn't is with prettier 1.5 ...

prettier.resolveConfig is not a function

in prettier-eslint

@CiGit I guess 馃憤

Suddenly I got this bug, before that I didn't update or install anything.

- VSCode Version: Code 1.16.1 (27492b6bf3acb0775d82d2f87b25a93490673c6d, 2017-09-14T16:24:39.530Z)
- OS Version: Darwin x64 16.7.0
- Extensions: 

Extension|Author (truncated)|Version
---|---|---
vscode-wakatime|Wak|1.1.16
project-manager|ale|0.21.1
theme-verdandi|be5|1.6.0
vscode-svgviewer|css|1.4.3
vscode-eslint|dba|1.3.2
githistory|don|0.2.3
json-tools|eri|1.0.2
prettier-vscode|esb|0.24.0
flow-for-vscode|flo|0.7.1
auto-close-tag|for|0.5.1
vscode-icon-theme|jtl|1.5.0
Go|luk|0.6.66

(1 theme extensions excluded)

@CiGit yes, I have been restarting every time I was changing something. But when I upgraded prettier and prettier-eslint, I noticed also a message from VSCODE: "installation appears to be corrupt", https://code.visualstudio.com/docs/supporting/faq#_installation-appears-to-be-corrupt so I updated to the last VSCode version 1.16.1, (my previous installation was 1 month old) . And then things worked.
Sorry it's not very helpful to pinpoint the problem. But I still think the issue was with outdated versions of prettier and prettier-eslint

@nguyennb9 the extensions auto update so it can be that the extension requires 1.7.x or that in your vscode workspace have a prettier: 1.7.x installed

@nealoke My team using prettier version 1.1.0, I think I need downgrade this extension to keep it work with prettier 1.1.0

npm update -D prettier

ctrl+shift+p -> Reload Window

This should work

I only had prettier-eslint-cli in my package.json, this solved it for me:

npm update -D prettier-eslint-cli

I got this today, @seancheung workaround worked for me 馃憤

Try adding this to workspace settings.
{ "prettier.eslintIntegration": false}
This worked for me

This is definitely a trouble with prettier-eslint.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GantMan picture GantMan  路  3Comments

Connorelsea picture Connorelsea  路  4Comments

ZiiMakc picture ZiiMakc  路  4Comments

bardware picture bardware  路  4Comments

DanielHabenicht picture DanielHabenicht  路  4Comments