0

When executing npm i -D react-router-dom, I am alerted to a couple of warnings regarding deprecated packages/dependencies (see the code snippet below). That's why I wanted to install the newest version of react-router-dom, but I don't know the correct command for it. Thanks for your help!

npm i -D react-router-dom

npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
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 urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm ERR! Maximum call stack size exceeded
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\WASSIM\AppData\Roaming\npm-cache\_logs\2021-12-08T12_15_23_618Z-debug.log
Luca
  • 151
  • 1
  • 13
  • npm i react-router-dom – Gautam Kothari Dec 08 '21 at 12:42
  • the `-D` stands for dev dependency, the correct command is `npm i react-router-dom --save` so it saves it to your package.json, check here: https://www.npmjs.com/package/react-router-dom, if you want to confirm your command for installation, also I recommend using a more advanced package manager such as `yarn` – JC ONG Dec 08 '21 at 12:47

1 Answers1

0

There are several ways to update your npm dependencies.

  1. Minor version upgrades
  2. Major version upgrades

For minor version upgrades (e.g. from version 1.0.0 to 1.0.5) you can simply run npm install. npm will then run upgrades for all dependencies that are used in the current project path.

In React.js applications, there is a file in your project path named package.json. If you want to do a major version upgrade (e.g. from version 1.0.0 to 2.0.0), you have to open the file and manually change the entry of react-router-dom. package.json has the following structure:

{
   "name": "name"
   "version": "1.0.0"
   ...
   "dependencies": {
      "react-router-dom": "5.3.0"
      ...
   }
}

If you want to upgrade for example from version 5.3.0 to 6.0.0, you would change it to:

{
   "name": "name"
   "version": "1.0.0"
   ...
   "dependencies": {
      "react-router-dom": "6.0.0"
      ...
   }
}

Sometimes sub-dependencies (i.e. other packages that are used in react-router-dom) are deprecated. I would not recommend to update them manually because other dependencies may be dependent on that particular version of a package. If you still want to have a look at it, have a look at this post.

Luca
  • 151
  • 1
  • 13