今天,我使用以下方法创建了一个使用CRA启动模板的reactjs:
npx create-react-app my-app --template redux这在我的项目中创建了两个文件:package.json和yarn.lock。
我不明白为什么我在项目中cd之后运行了yarn start,尽管我没有用yarn create react-app my-app启动这个项目。
我有两个问题:
它生成yarn.lock?
npx create-react-app my-app --template redux andyarn create react-app my-app --template redux之间的区别,考虑到它们具有相同的effect.发布于 2020-08-05 13:39:10
npx create-react-app执行create-react-app二进制文件,create-react-app使用yarn创建项目(如果安装了纱线)。这就是您可以看到yarn.lock的原因,也是yarn-start工作的原因。
在
npx create-react-app和yarn create react-app中的差异
它们都执行create-react-app二进制文件。create-react-app是决定是否要用纱线创建项目的人。要在create-react-app中使用create-react-app,请使用--use-npm标志(无论您使用npx、yarn还是directly执行create-react-app,如果希望使用npm,都应该设置它):
create-react-app my-project --use-npm发布于 2020-08-05 13:43:19
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.https://stackoverflow.com/questions/63266392
复制相似问题