为什么 `npm init react-app` 默认使用 yarn? (npm V6.14.5)
Why is `npm init react-app` using yarn as default? (npm V6.14.5)
当 运行 npm init react-app
npm 选择 yarn 作为创建的应用程序的默认包管理器时。我已经使用 How Do I Uninstall Yarn.
中的 boj answer 从我的计算机中删除了 yarn
最小可重现示例:
$ npm -v
6.14.5
$ npm init react-app my-app
npx: installed 98 in 13.198s
Creating a new React app in ./my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
yarn add v1.9.4
...
$ cd my-app
my-app/$ ls
node_modules package.json yarn.lock public README.md src
如您所见,有一个 yarn.lock 文件,并且使用 yarn add v1.9.4 来安装软件包。这是 npm V6.14.5 现在的默认 npm 行为吗?如果是的话,很高兴知道是否有参考资料可以找到我选择 yarn 作为默认值的原因。
这只是反应应用程序创建者的偏好。顺便说一句,如果您更愿意使用 npm
.
,则可以使用 --use-npm
原因可能是 yarn
是与 Facebook 团队一起构建的,因此他们希望在 npm
上使用它。
如果您愿意,可以使用--use-npm
npm
:
create-react-app my-project --use-npm
如果项目已经创建,请尝试删除yarn.lock
您可以使用 npx create-react-app project-name --use-npm
以便默认为 npm
当 运行 npm init react-app
npm 选择 yarn 作为创建的应用程序的默认包管理器时。我已经使用 How Do I Uninstall Yarn.
最小可重现示例:
$ npm -v
6.14.5
$ npm init react-app my-app
npx: installed 98 in 13.198s
Creating a new React app in ./my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
yarn add v1.9.4
...
$ cd my-app
my-app/$ ls
node_modules package.json yarn.lock public README.md src
如您所见,有一个 yarn.lock 文件,并且使用 yarn add v1.9.4 来安装软件包。这是 npm V6.14.5 现在的默认 npm 行为吗?如果是的话,很高兴知道是否有参考资料可以找到我选择 yarn 作为默认值的原因。
这只是反应应用程序创建者的偏好。顺便说一句,如果您更愿意使用 npm
.
--use-npm
原因可能是 yarn
是与 Facebook 团队一起构建的,因此他们希望在 npm
上使用它。
如果您愿意,可以使用--use-npm
npm
:
create-react-app my-project --use-npm
如果项目已经创建,请尝试删除yarn.lock
您可以使用 npx create-react-app project-name --use-npm
以便默认为 npm