create-react-app 不生成 package.lock 文件
create-react-app not generating package.lock file
今天我在做一个 React Web 项目。所以它起作用了 fine.And 然后我创建了另一个反应项目。但是那里没有任何 package.lock 文件。所以我使用 npm install
手动创建了它。但是在那之后,当我使用 npm i react-particles-js
命令向该项目添加依赖项时,我收到了这样的错误消息。
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: smart-parking-system@0.1.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR! react@"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0.0" from react-particles-js@3.5.3
npm ERR! node_modules/react-particles-js
npm ERR! react-particles-js@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\User.LAPTOP-3EBUUP6S\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User.LAPTOP-3EBUUP6S\AppData\Local\npm-cache\_logs21-09-02T11_17_21_426Z-debug.log
另外,当我手动创建 package.lock 文件时,我收到此日志消息。
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
changed 87 packages, and audited 1703 packages in 40s
所以问题是为什么我没有自动获取 package.lock 文件以及为什么我不能正确安装依赖项?
可能是creat-react-app现在使用yarn了
- 而不是
npm install
使用 yarn
- 而不是
npm i react-particles-js
使用 yarn add react-particle-js
您可以确认您是否有 yarn.lock
文件
今天我在做一个 React Web 项目。所以它起作用了 fine.And 然后我创建了另一个反应项目。但是那里没有任何 package.lock 文件。所以我使用 npm install
手动创建了它。但是在那之后,当我使用 npm i react-particles-js
命令向该项目添加依赖项时,我收到了这样的错误消息。
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: smart-parking-system@0.1.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR! react@"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0.0" from react-particles-js@3.5.3
npm ERR! node_modules/react-particles-js
npm ERR! react-particles-js@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\User.LAPTOP-3EBUUP6S\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User.LAPTOP-3EBUUP6S\AppData\Local\npm-cache\_logs21-09-02T11_17_21_426Z-debug.log
另外,当我手动创建 package.lock 文件时,我收到此日志消息。
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
changed 87 packages, and audited 1703 packages in 40s
所以问题是为什么我没有自动获取 package.lock 文件以及为什么我不能正确安装依赖项?
可能是creat-react-app现在使用yarn了
- 而不是
npm install
使用yarn
- 而不是
npm i react-particles-js
使用yarn add react-particle-js
您可以确认您是否有 yarn.lock
文件