Parsing error : Cannot find module 'next/babel'


更新1:Updated the latest working solution to @Jeevan Rupacha answer, please scroll below to check it out.

我一直在我创建的每个新的Next.js项目上遇到此错误。可以在没有任何问题的情况下编译该页面,它只是在每个JS文件中的第一行中都显示为错误。

解析错误:找不到模块“ next/babel' 需要堆栈:

  • D:\app\next_app\ratu-seo\node_modules\next\dist\compiled\babel\bundle.js
  • D:\app\next_app\ratu-seo\node_modules\next\dist\compiled\babel\eslint-parser.js
  • D:\app\next_app\ratu-seo\node_modules\eslint-config-next\parser.js
  • D:\app\next_app\ratu-seo\node_modules@eslint\eslintrc\lib\config-array-factory.js
  • D:\app\next_app\ratu-seo\node_modules@eslint\eslintrc\lib\index.js
  • D:\app\next_app\ratu-seo\node_modules\eslint\lib\cli-engine\cli-engine.js
  • D:\app\next_app\ratu-seo\node_modules\eslint\lib\cli-engine\index.js
  • D:\app\next_app\ratu-seo\node_modules\eslint\lib\api.js
  • c:\Users\Admin.vscode\extensions\dbaeumer.vscode-eslint-2.1.23\server\out\eslintServer.js

创建调用文件.babelrc在您的根目录中添加此代码:


{
  "presets": ["next/babel"],
  "plugins": []
}
  

并在.eslintrc,将现有代码替换为:


{
  "extends": ["next/babel","next/core-web-vitals"]
}
  

Parsing error : Cannot find module 'next/babel'的相关文章

随机推荐