LoginSignup
25
14

More than 5 years have passed since last update.

【npm】エラー解決:We noticed you're using the useBuiltIns option without declaring a core-js version. Currently, we assume version 2.x when no version is

Last updated at Posted at 2019-03-23

npm update して gulp のタスクを走らせたところ、以下のメッセージが。
超意訳「core-js のバージョン指定なしで useBuiltIns オプションを使ってるよ(略)」

$ npx gulp watch

Requiring external module @babel/register

WARNING: We noticed you're using the `useBuiltIns` option without declaring a core-js version. Currently, we assume version 2.x when no version is passed. Since this default version will likely change in future versions of Babel, we recommend explicitly setting the core-js version you are using via the `corejs` option.

You should also be sure that the version you pass to the `corejs` option matches the version specified in your `package.json`'s `dependencies` section. If it doesn't, you need to run one of the following commands:

  npm install --save core-js@2    npm install --save core-js@3
  yarn add core-js@2              yarn add core-js@3

gatsbyjs の Issues にあった解決法で解決できた。

core-js@2 と core-js@3 どっちを指定すべきかわからなかったので、@babel/preset-env (7.3.4 → 7.4.2) と @babel/register (7.0.0 → 7.4.0) が 依存している core-js が共に v3 であることを確認。.babelrc に下記の通りバージョンを追加した。以上。

// 変更前
{
  "presets": [
    [
      "@babel/preset-env",
      {
        "useBuiltIns": "usage",
        "corejs": 3 // ← バージョンを追加
      }
    ]
  ]
}

なお、警告文にある通り、指定なしだとバージョン2が指定されるようになっており、放置したとしても当面は問題ないみたい。

25
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
14