Adding a package immediately after created by create-react-app is not working

You are using npm 5. At the moment it has many issues.

I recommend to downgrade to npm 4 and try again:

npm install -g npm@4

rm -rf node_modules
rm package-lock.json
npm install

If it doesn't help check your internet connection. This looks like an issue with your network:

getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443


I got the answer, since I had yarn and npm both installed in my machine the create-react-app uses yarn and installs all the dependencies and creates yarn.lock file.

So now when I run npm install it looks for package.lock.json and it wont be there. So it uninstalls some package creates by yarn at the time of creation of the project.

So the solution I found is do any of the following

  • create-react-app my-app
  • npm install
  • Then do install npm install -package-

Or

Both of this approach is working now for me.