npm - 这个错误是什么意思?有 `useBuiltIns` 选项,需要直接设置 `corejs` 选项

标签 npm babeljs

我刚开始在使用 parcel.js 构建静态 Assets 时遇到此错误。它在本地工作,但我在 Heroku 上的构建出错,我不确定它是否相关。

最佳答案

得到同样的问题。通过将 core-js 安装为顶级依赖项,然后将其添加为 .babelrc 的选项来解决它

npm install --save core-js@3

然后更新我的 .babelrc 文件以将其包含为一个选项:
 {
  "presets": [
    [ "@babel/preset-env", {
      "useBuiltIns": "entry",
      "corejs": 3
    }]
  ],
  "plugins": [
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-syntax-import-meta",
    ["@babel/plugin-proposal-class-properties", { "loose": false }],
    "@babel/plugin-proposal-json-strings"
  ]
}

我引用了这里的文档来弄清楚 https://babeljs.io/docs/en/babel-preset-env#usebuiltins

关于npm - 这个错误是什么意思?有 `useBuiltIns` 选项,需要直接设置 `corejs` 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55251983/

相关文章:

node.js - 未找到自动前缀命令

visual-studio - 命名空间 'React' 没有导出成员 'InputHTMLAttributes' 和接口(interface) 'MenuItemProps' 错误地扩展了接口(interface) 'ListItemProps'

node.js - 尝试从 npm 安装 Angular 2 Material - 源文本中无法识别的标记

node.js - 在 Nodejs 中使用 async await 与 redis 和 bluebird

reactjs - React Native - 将选项allowNamespaces传递给babel typescript 插件

javascript - 错误 : bundling failed: TypeError: Cannot read property 'bindings' of null

node.js - 由于 SELF_SIGNED_CERT_IN_CHAIN,Expo 无法更新 npm 包

javascript - 尝试通过 mocha 调试程序(使用 --debug-brk)调试 mocha 本身

reactjs - 使用 babel-jest 来开 Jest 但仍然出现语法错误

webpack - "The code generator has deoptimised the styling of [some file] as it exceeds the max of "100KB""是什么意思?