6

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?

Soccerball123
  • 741
  • 5
  • 17
  • If the solution is to downgrade react-scripts from 5.x to 4.x, that's almost certainly not the actual solution. Which version of node are you using? Because Node 16 (the current LTS) should work fine, whereas Node 18 (the current active) does not. And if you don't want to constantly reinstall Node, use [nvm](https://github.com/nvm-sh/nvm#installing-and-updating) or [nvm-windows](https://github.com/coreybutler/nvm-windows#installation--upgrades) (depending on your OS) to make using different Node versions without constantly reinstalling a trivial task. – Mike 'Pomax' Kamermans Jul 08 '22 at 15:07

2 Answers2

9

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 react-scripts@4.0.3

Yarn

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

uninstall:

yarn remove react-scripts

install:

yarn add react-scripts@4.0.3
Michal Miky Jankovský
  • 3,089
  • 1
  • 35
  • 36
DᴀʀᴛʜVᴀᴅᴇʀ
  • 7,681
  • 17
  • 73
  • 127
2

You have at least 2 options.

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

npm i react-scripts@4.0.3

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.

Botond Balogh
  • 163
  • 1
  • 9