Search code examples
reactjsnode.jsnpmnpm-install

Unable to install redux and datepicker using npm


Tried using the following npm command to install redux, react-datepicker, and react-router-dom.

npm i react-redux @reduxjs/toolkit  react-datepicker react-router-dom@6

I noticed package.json isn't getting updated and the following is outputted in the terminal:

up to date, audited 157 packages in 16s

22 packages are looking for funding
  run `npm fund` for details

15 high severity vulnerabilities

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

I tried npm set registry=https://registry.npmjs.org/ after checking Stackoverflow.

How to solve this?

Package.json

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },

Expecting react-datepicker, react-redux, and the others to be added here.


Solution

  • The packages were installed, the vulnerability warnings are just warnings though, and can generally be ignored. Run npm audit fix if you want to update/fix them.

    Make sure you are in the correct directory for installing project dependencies, e.g. the project's root directory, then try running the following:

    npm i -S react-redux @reduxjs/toolkit react-datepicker react-router-dom@6
    

    This should install and update the package.json file. The -S or --save flag does this in older Node and NPM versions.