解析错误:找不到模块'next/babel' [英] Parsing error : Cannot find module 'next/babel'

查看:15
本文介绍了解析错误:找不到模块'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:app ext_app atu-seo ode_modules extdistcompiledabelundle.js
  • D:app ext_app atu-seo ode_modules extdistcompiledabeleslint-parser.js
  • D:app ext_app atu-seo ode_moduleseslint-config-nextparser.js
  • D:app ext_app atu-seo ode_modules@eslinteslintrclibconfig-array-factory.js
  • D:app ext_app atu-seo ode_modules@eslinteslintrclibindex.js
  • D:app ext_app atu-seo ode_moduleseslintlibcli-enginecli-engine.js
  • D:app ext_app atu-seo ode_moduleseslintlibcli-engineindex.js
  • D:app ext_app atu-seo ode_moduleseslintlibapi.js
  • c:UsersAdmin.vscodeextensionsdbaeumer.vscode-eslint-2.1.23serverouteslintServer.js
  • D:app ext_app atu-seo ode_modules extdistcompiledabelundle.js
  • D:app ext_app atu-seo ode_modules extdistcompiledabeleslint-parser.js
  • D:app ext_app atu-seo ode_moduleseslint-config-nextparser.js
  • D:app ext_app atu-seo ode_modules@eslinteslintrclibconfig-array-factory.js
  • D:app ext_app atu-seo ode_modules@eslinteslintrclibindex.js
  • D:app ext_app atu-seo ode_moduleseslintlibcli-enginecli-engine.js
  • D:app ext_app atu-seo ode_moduleseslintlibcli-engineindex.js
  • D:app ext_app atu-seo ode_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'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆