prettier-vscode: Cannot find module '../ast-utils' when formating
Hi all,
I’m getting the following error after installing prettier-vscode and trying to format a file.
Cannot find module '../ast-utils'
I have no idea about what’s happening.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 68
- Comments: 68 (2 by maintainers)
Same problem here with
eslint 6
.rm -rf node_modules
andnpm i
did not help.Error:
Cannot find module '../util/ast-utils'
Incase this is still an issue, I found that changing
"prettier.eslintIntegration": true
to
"prettier-eslint.eslintIntegration": true
in Settings (JSON) for VS Code fixed all the issues with prettier and eslint. I’ve managed to upgrade to the latest version of prettier and eslint and things are working as expected.
Hi, Same error solved by remplacing the User Settings.json file in vs code. Make it basic like that
{ “terminal.integrated.fontFamily”: “Fira mono for Powerline”, “window.zoomLevel”: 1, “editor.formatOnSave”: true }
Looks like I have the same problem. Re-installing node_modules with yarn didn’t do it for me. I’m using eslint 6.0.
I am using
"prettier.eslintIntegration": false
for now and that works. Not sure if I need it.None of the mentioned solutions do the trick for me.
With
eslint@6.0.1
it couldn’t read any plugin, got the error @0x80 mentioned.With
eslint@5.16.0
it couldn’t findast-utils
, got the error @frederikhorsI think it’s related to
eslint
version as I am using this setting"prettier.eslintIntegration": true
and it’s what causing the issue and this issue just happened to me after upgrading to eslint version^5.12.0
@dijam @adriangrahl Is VSCode called MSCode now? Did I miss the memo?
@nfantone I’ve tried all the possible solutions out there. The only thing that works is disabling
prettier.eslintIntegration
. I’m almost positive this is an error inprettier-vscode
while using enabling ESLint integration.had the same issue, @swansontec was right, had two eslints in my node_modules
rm -rf node_modules && yarn
solved my issues@CiGit this is urgent now with the new eslint 6 released.
This issue isn’t the real issue, this is just a consequence. The real problem come from prettier-vscode compatibility with ESlint 6… This topics is becoming a mess a bit more each day and it should be close in favor of #870 !
delete eslint Getting better
I have to downgrade eslint version because the issue. I hope the solution will come.
Yes, but it’s strange that it’s been working with that enabled for so long now, and suddenly in the last 3-4 days, it breaks.
I am not using
eslint-plugin-node
andeslint-plugin-promise
, but everything else is the same version:Still doesn’t work.
Setting
prettier.eslintIntegration
tofalse
works for now.Neither ESLint
5.16
or^6
works. Only5.4
works for me. For6.x
, there’s this error https://github.com/microsoft/vscode-eslint/issues/696Updating MSCode to 1.36.0 fixed the issue for me too.
The error doesn’t provide much context, so I did
grep ast-utils -R node_modules/
. All the hits were inside eslint, so this is almost certainly an eslint issue. I noticed that my node_modules folder had two copies of eslint, since my project depended on a different version (5.9.0) than prettier-eslint itself (^4.0.0).Switching my project to depend on the same eslint as prettier-eslint (specifically, ^4.0.0) solved the problem for me.
please help
I had the same weird problem. I use eslint with eslint-plugin-prettier together. Somehow this was colliding with VSCode prettier plugin. After i disabled VSCode prettier plugin and using only eslint it was working again. Also had to set “eslint.autoFixOnSave” to true.
downgrade 5.4.0 . it works !!!
I had similar problem for a while. I did everything possible. Downgrading and use fix versions. Even copy-paste from other folders/projects that work but didn’t work. Tried empty project with exact packages and it worked but when implement the same in my current project it wouldn’t. But, when Code released the new version, all went back to normal 😃 I assume MSCode was using some packages that messed up my configs that technically should have the highest priority when loading eslint config. Anyway, All good and I can work again 😃 My current versions:
"eslint": "^5.16.0","prettier": "^1.17.0",
MSCode version:1.36.0
Also, there is another thing a little strange. Before I went back to
5.16.0
, I try to downgrade eslint version…like5.14.0
, then5.12.0
, and then5.8.0
. Finally5.4.0
works well. But when I tried to upgrade, even5.14.0
can work. Every time I changed the version, I reloaded vscode and make sure that there were no copied versions in node_modules. But back to6.0.1
error of this issue occured. Then5.16.0
, another error. But after I remove one of the rules (just I mentioned above). Every thing went well. I don’t even know whether the same problem will occur again tomorrow…QAQJust ran into this as well so I assume this is about to really hit the fan if not updated soon since I just went through updating eslint across our repos. Luckily google gets here as the top result so it wasn’t a time consuming thing to troubleshoot.
Note that with the issue that @0x80 ran into you simply need to reload the VSCode Window (
Cmd + Shift + P --> Reload Window
)Seems “prettier.eslintIntegration” config is now deprecated. there are a deprecation notice and solution in the readme: https://github.com/prettier/prettier-vscode#vscode-eslint-and-tslint-integration
on
eslint "^5.16.0", "prettier": "^1.18.2"
And it works for me if I delete all modules about eslint and reinstall them
At the current, my working solution is disable ESlint Integration setting in vscode while waiting for new update version.
[1] Turn off ESlint Integration setting in vscode
[2] Install eslint, eslint-config-google (I’m using config from Google)
The newest version will be:
[3] Configure eslint and prettier to make it work as expected
.eslintrc.json
.prettierrc
With this configuration, I got the result as expected before getting error 😄 😄 😄
@EthanNYT
No, not really. There are
eslint-plugin-prettier
andeslint-config-prettier
that handle that for you. Andprettier
doesn’t even need one (defaults work well enough). Although, there’s nothing preventing you from configuring them separately.Plugins above, if kept up to date, will make sure changes in
prettier
don’t mess up witheslint
rules and viceversa. And on that same note, once you settle on a set of rules that makes sense for you (or your organisation), you very rarely modify them, in my experience. And not entirely sure what that “etc.” would encompass. There’s honestly nothing else to it.Those would still apply and won’t conflict with each other. What would the issue be here?
Here’s my typical
eslint
+prettier
configuration fornode
projects (I like to usestandard
+ semicolon).That’s all you need. No
prettier-eslint
, at all.Then I’d need an ESLint config file and a Prettier config file, right? And have to make sure any changes you make to one you have to make to the other, etc.
Also, it seems that ESLint has many settings that are missing from Prettier.
@samrith-s I was actually going to ask you this (check the “Edit” history on my previous comment!). I’m on LTS.
But, anyway, I’d ditch
prettier-eslint
entirely. Doesn’t have much use other than facilitating initial setup - which, if you have been working on 50+ projects in the past like it was mentioned, should not pose a problem.Your answer works
My Eslint version is 6.0.1 . It got wrong in vscode .
When I install Eslint 4.0.0 , everything was OK.
https://github.com/benmosher/eslint-plugin-import/pull/1393 is merged and release but still the same problem. This is urgent. I’m crying…
I did a global uninstall and a local uninstall then reinstalled everything locally and now things are working.
Downgrade eslint to previous working version not helped. I’m getting this issue.
Yep, ditching it entirely from now on, so that no such problem occurs. Thanks a lot @nfantone for that comment, helped me debug in that direction! 😁
@nfantone I’ve upgraded all my dependencies to latest, removed node_modules and yarn.lock and reinstalled + restarted vscode.
Still the same ast-utils error for me. This is with versions:
I’m positive.
This is my go-to setup. I’ve used it in 50+ projects and it has always worked. Somehow, every single project broke in the last 3-4 days.
I’ve managed to get this working again with latest
eslint-config-prettier
released some hours ago. Here’s what I have:@iRoachie, have you tried
rm -rf node_modules
and then runningnpm
oryarn
again as @mrsufgi suggested?