0

Today I worked on a react web project. So it worked fine.And then after that I created a another react project. But in that there was no any package.lock file. So I created manually it by using npm install . But after that when I'm adding dependency to that project with npm i react-particles-js command I got a error msg like this.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
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 [email protected]
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\_logs\2021-09-02T11_17_21_426Z-debug.log

Also when I'm creating package.lock file manually I get this log message.

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 [email protected]: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated [email protected]: 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

So the problem is why I'm not getting a package.lock file automatically and why I can't install dependencies correctly?

2
  • have you tried installing with npm i package name ----legacy-peer-deps Commented Sep 2, 2021 at 11:36
  • Yeah. now it's working fine. But why is that happen. I worked fine with the react before that. But now the problem is why is it not creating a package.lock file automatically. It worked fine before. Does that happen because new create-react-app version using only yarn now? Commented Sep 2, 2021 at 11:53

1 Answer 1

1

It can be because creat-react-app is using yarn now.

  • Instead of npm install use yarn
  • Instead of npm i react-particles-js use yarn add react-particle-js

You can confirm if you have a yarn.lock file

Sign up to request clarification or add additional context in comments.

1 Comment

Yes it's generating a yarn.lock file. Yesterday when I'm creating react app, I got yarn.lock and also the package.lock file also. Does this happen because new create-react-app version is using yarn instead of npm? I knew it today. And Thank you so much for answering this question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.