gpt4 book ai didi

javascript - 将 ES6 编译为 ES5 需要 babel-cli 加上预设吗?

转载 作者:行者123 更新时间:2023-12-03 02:55:02 25 4
gpt4 key购买 nike

仅在本地安装所谓的“babel-cli”以及项目文件夹中的预设(es2015、react 等)来编译 ES6 代码是否足够?

就这些了吗?

我记得还有另一个模型“babel”,必须全局安装。

最佳答案

您可以在本地或全局安装 Babel(即 babel-cli),这是您的选择。 Babel 作者推荐本地安装,引用自documentation :

While you can install Babel CLI globally on your machine, it’s much better to install it locally project by project.

There are two primary reasons for this.

  1. Different projects on the same machine can depend on different versions of Babel allowing you to update one at a time.
  2. It means you do not have an implicit dependency on the environment you are working in. Making your project far more portable and easier to setup.

所以你的问题的答案是:是的,就是这样。

关于javascript - 将 ES6 编译为 ES5 需要 babel-cli 加上预设吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47672397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com