相关文章推荐
有情有义的香烟  ·  reactjs - How to run ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have setup the Stencil CLI and it was working fine, until a few weeks ago, when it started giving me the error:

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

I have updated the node version, reinstalled npm multiple times but with no effect. Also have run the commands mentioned above.

Can someone please help me in fixing this issue? Thanks a lot! Shivam

You only have to add corejs: 2 or corejs: 3 to your preset options depending on what version you're using:

In babel.config.js

const presets = [['@babel/preset-env', { useBuiltIns: 'usage', corejs: 2 }]];
module.exports = { presets };

In .babelrc

"presets": [ "@babel/preset-env", "useBuiltIns": "usage", "corejs": 2

You can read about other allowed values here: https://babeljs.io/docs/en/next/babel-preset-env#corejs

I made some notes and a working configuration of babel7 here: https://github.com/hdt94/notes-babel

Hope this helps

Also, several commenters successfully stopped the warnings by making the changes described in this vuejs issue report:

  • Fix babel useBuiltIns core-js warning #1471
  • Hope that helps,

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.