Home > front end >  How do I downgrade react-scripts 5.0.1 to 4.0.3
How do I downgrade react-scripts 5.0.1 to 4.0.3

Time:07-08

I'm having the issue that's faced in this question: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema

One of the solutions is to downgrade react-scripts to 4.0.3 and I'm not sure how to do that. Could someone help me?

CodePudding user response:

Could always delete your node_modules directory and change the version in your package.json under dependencies:

"dependencies": {
  "react-scripts" :"5.0.1",
}

then run an install. It's better to do a terminal approach when looking to change versions of a package, like:

NPM

uninstall:

npm uninstall react-scripts

install:

npm install --save [email protected]

Yarn

since Yarn is the preferred for Create React App per memory:

uninstall:

yarn remove react-scripts

install:

yarn install [email protected]

CodePudding user response:

You have at least 2 options.

First, in your project folder you run the following command:

npm i [email protected]

Source: https://www.npmjs.com/package/react-scripts/v/4.0.3?activeTab=versions

Second, you open your package.json file in your project and change the version number of react-scripts to 4.0.3

"dependencies": {
   "react-scripts" :"4.0.3",
   ...
}

and run npm i.

This will upgrade or downgrade everything to the version that are stated in your package.json file.

  • Related