reactjs - 升级到 Babel 7 后出现错误

标签 reactjs babeljs

运行npm start时抛出此错误

/Users/Gabe/esports-calendar/node_modules/@babel/core/lib/config/config-descriptors.js:178
    throw new Error(`Plugin/Preset files are not allowed to export objects, only functions. In ${filepath}`);
          ^

Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Plugin/Preset files are not allowed to export objects, only functions. In /Users/Gabe/esports-calendar/node_modules/babel-preset-es2015-ie/index.js

最佳答案

我建议您在运行 npmauditfix --force 之前将此项目重置为它的状态。假设您使用 git 进行版本控制,如果是这样,您可以运行 git reset --hard 来将当前分支设置为最后一次提交。

出现这种情况的原因是您尝试手动将项目更新到 babel 7。Razzle 无法以这种方式工作;其目标是通过消除开发人员的某些责任来简化开发人员工具。

  1. 进入 package.json 文件并更改 razzle 的版本:
"devDependencies": {
  "razzle": "^3.0.0",
  etc...
}
  • 删除您的 node_modules 目录。

  • 执行 npm i 重新安装软件包。

  • 关于reactjs - 升级到 Babel 7 后出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57191949/

    相关文章:

    javascript - Redux Devtool(chrome 扩展)不显示状态

    javascript - ReactJS:如何在 <DropDownMenu/> 中动态呈现 Material-UI 的 <MenuItem/>?

    javascript - react native : Error while downgrading from 0. 51 到 0.45

    javascript - 语法错误 : Invalid or unexpected token when testing react application with babel and jest

    javascript - Webpack 抛出 JSX 语法错误

    javascript - 开 Jest 测试 'unexpected token export'

    javascript - Next.js 视口(viewport)元标记不应在 _document.js 的 <Head> 中使用

    css - 如何从 Material UI TextField React 组件中删除 flex 边框和插入框阴影?

    javascript - 包含了 babel polyfill,但是 forEach 在 IE11 的 NodeLists 上仍然不起作用

    javascript - 使用 babel 时 Nodemon 在保存时运行多次