简体   繁体   English

解析错误:在我的 Next.js 应用程序中找不到模块“next/babel”

[英]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:准确地说出我已经尝试过的解决方案类型:

  • Adding next/babel in the .eslintrc.json.eslintrc.json添加next/babel
  • installing 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.

相关问题 解析错误:找不到模块“next/babel” - Parsing error: Cannot find module 'next/babel' 解析错误:找不到模块“next/babel” - Parsing error : Cannot find module 'next/babel' 错误:找不到模块 '/next'、docker、next.js - Error: Cannot find module '/next', docker, next.js Next.js 中的 babel 和 tailwindcss 问题:找不到模块“xwind/babel” - Problem with babel and tailwindcss in Next.js: Cannot find module 'xwind/babel' Next.js:模块构建失败:错误:无法从“/home/ugurkaya/Desktop”中找到模块“react-hot-loader/babel” - Next.js: Module build failed: Error: Cannot find module 'react-hot-loader/babel' from '/home/ugurkaya/Desktop' 在 Next.js 上使用 jest 找不到模块错误 - Cannot find module error using jest on Next.js 错误:在 next.js 中找不到模块“swiper/react” - Error: Cannot find module 'swiper/react' in next.js Netlify Next.js 部署错误:找不到模块“esbuild” - Netlify Next.js deploy error: Cannot find module ‘esbuild’ 错误:找不到模块“tailwindcss”(Next.js 应用程序) - Error: Cannot find module 'tailwindcss' (Next.js application) 捆绑express.js和next.js app抛出错误:找不到模块next.config.js' - Bundling express.js and next.js app throwing Error: Cannot find module next.config.js'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM