本文介绍了解析错误:找不到模块'next/babel'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在创建的每个新 Next.js 项目中都遇到此错误.该页面可以毫无问题地编译,它只是在每个js文件的第一行一直显示为错误.
I have been encountering this error on every single new Next.js project that I create. The page can be compiled without any problem, it just keeps on showing as error on the first line in every js file.
解析错误:找不到模块next/babel"需要堆栈:
Parsing error: Cannot find module 'next/babel'Require stack:
- D:appext_appatu-seoode_modulesextdistcompiledabelundle.js
- D:appext_appatu-seoode_modulesextdistcompiledabeleslint-parser.js
- D:appext_appatu-seoode_moduleseslint-config-nextparser.js
- D:appext_appatu-seoode_modules@eslinteslintrclibconfig-array-factory.js
- D:[email protected]
- D:appext_appatu-seoode_moduleseslintlibcli-enginecli-engine.js
- D:appext_appatu-seoode_moduleseslintlibcli-engineindex.js
- D:appext_appatu-seoode_moduleseslintlibapi.js
- c:UsersAdmin.vscodeextensionsdbaeumer.vscode-eslint-2.1.23serverouteslintServer.js
- D:appext_appatu-seoode_modulesextdistcompiledabelundle.js
- D:appext_appatu-seoode_modulesextdistcompiledabeleslint-parser.js
- D:appext_appatu-seoode_moduleseslint-config-nextparser.js
- D:appext_appatu-seoode_modules@eslinteslintrclibconfig-array-factory.js
- D:[email protected]
- D:appext_appatu-seoode_moduleseslintlibcli-enginecli-engine.js
- D:appext_appatu-seoode_moduleseslintlibcli-engineindex.js
- D:appext_appatu-seoode_moduleseslintlibapi.js
- c:UsersAdmin.vscodeextensionsdbaeumer.vscode-eslint-2.1.23serverouteslintServer.js
推荐答案
在你的根目录下创建名为 .babelrc
的文件,并添加以下代码:
Create file called .babelrc
in your root directory and add this code:
{
"presets": ["next/babel"],
"plugins": []
}
并且在.eslintrc
中,将现有代码替换为:
And in .eslintrc
, replace the existing code with:
{
"extends": ["next/babel"]
}
这篇关于解析错误:找不到模块'next/babel'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!