Vik*_*Ray 16 reactjs yarnpkg npx
今天我使用 CRA 创建了一个 reactjs 起始模板:
npx create-react-app my-app --template redux
Run Code Online (Sandbox Code Playgroud)
这在我的项目中创建了两个文件:package.json和yarn.lock.
我很困惑为什么它在我cd进入项目后工作并运行,yarn start即使我没有用yarn create react-app my-app.
我有两个问题:
npx create-react-app my-app --template redux 和yarn create react-app my-app --template redux 考虑到它们具有相同的效果。yay*_*aya 25
npx create-react-app执行create-react-app二进制文件,并create-react-app用于yarn创建您的项目(如果安装了yarn)。这就是为什么你可以看到yarn.lock,也是为什么yarn-start有效。
npx create-react-app和之间的区别yarn create react-app
他们都执行create-react-app二进制。create-react-app是决定是否要使用纱线创建项目的人。要npm在 in中使用create-react-app,请使用--use-npm标志(无论您create-react-app使用npx或执行yarn还是使用directly,如果您希望它使用 ,就应该设置它npm。):
create-react-app my-project --use-npm
Run Code Online (Sandbox Code Playgroud)
小智 5
create-react-app 如果安装了纱线,则使用纱线进行设置。
因此,如果您的系统中已经安装了纱线,那么npx create-react-app my-app --template redux和yarn create react-app my-app --template redux会给您相同的最终结果。
它已经安装在您的系统中,这就是为什么它生成了 yarn.lock 而不是 package.lock。
yarn.lock is generated to keep the exact version of the installed packages.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10316 次 |
| 最近记录: |