I'm new to working with Sanity, and just set up a project. Everything is working fine, however, in Visual Studio Code, I keep getting a parsing error that won't disappear, and I'm wondering how I can fix it.
Parsing error: Cannot find module '@babel/preset-env'
I've tried deleting the node_modules
and re-running sanity install
, I've also tried using npm install
to install @babel/core
and @babel/preset-env
. Nothing seems to have fixed the problem so far.
Any suggestions? I want to start using Sanity with my team at work, but having this error is really quite annoying (as everything is underlined in red).
I was having a similar issue. For me, the issue was related to the way VS Code deals with a project containing multiple ESLint working directories (common in monorepos).
For example
Project
|--- /web
|--- /studio
In my project root, edit (or create) ./.vscode/settings.json
to include my ESLint projects. NB: these settings only apply to your current workspace.
"eslint.workingDirectories": ["./web", "./studio"]
Hope that helps :-)
Method 1:
Create a file called .babelrc in your root directory and add this code
{
"presets": ["next/babel"],
"plugins": []
}
And in .eslintrc replace the existing code with
{
"extends": ["next/babel"]
}
Method 2:
You need to install npm with this command:
npm install --save-dev @babel/core @babel/preset-env
or
npm install --save-dev @babel/core
I hope this will solve your problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.