[英]Parsing error: Cannot find module 'next/babel' in my Next.js app
I know there are a lot of answers like this , this or this out there and some people may flag my question as duplicate, but believe me I am struggling with this because neither of them is working for me now.我知道有很多这样的答案,有些人可能会将我的问题标记为重复,但请相信我,我正在努力解决这个问题,因为他们现在都不适合我。 Those were working before but looks like the solution is depreciated or expired.
那些以前工作但看起来解决方案已贬值或过期。
I have no idea about eslint whatsoever, the only thing I like about eslint is that it underlines the unimported/undeclared variables with red line, that's why I installed eslint extension in my VS Code editor.我完全不知道 eslint,我唯一喜欢 eslint 的是它用红线强调了未导入/未声明的变量,这就是我在 VS 代码编辑器中安装 eslint 扩展的原因。
Also, I am not opening the code directory directly in my VS Code, I have other projects too in the same workspace, eg I have a structure like this:另外,我没有直接在我的 VS Code 中打开代码目录,我在同一个工作区中也有其他项目,例如我有这样的结构:
| -- some_folder
| | -- project_1
| | -- project_2
| ...files relating to both projects...
Starting a fresh Next.js project should not be coming up with any errors, don't know what am I doing wrong.开始一个新的 Next.js 项目应该不会出现任何错误,不知道我做错了什么。
This is my .eslintrc.json
:这是我的
.eslintrc.json
:
{
"extends": "next"
}
And this is the .babelrc
:这是
.babelrc
:
{
"presets": ["next/babel"],
"plugins": []
}
To tell exactly what type of solutions I already tried:准确地说出我已经尝试过的解决方案类型:
next/babel
in the .eslintrc.json
.eslintrc.json
添加next/babel
babel-eslint
but nothing helped!babel-eslint
但没有任何帮助! instead of this in eslintrc.json { "extends": "next" } use this { "next/babel","next/core-web-vitals", } I think this will fix the issue.而不是在 eslintrc.json { "extends": "next" } 中使用这个 { "next/babel","next/core-web-vitals", } 我认为这会解决这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.