Skip to content

'react-scripts start' command fails with node 18.0.0 if "proxy" entry is present in package.json #12316

@Kais3rP

Description

@Kais3rP

Describe the bug

When I try to start the development server with "npm run start", the 'react-scripts start' command fails, throwing this exception:
`Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.

  • options.allowedHosts[0] should be a non-empty string.
    error Command failed with exit code 1.`

This happens only by switching to Node.js version 18.0.0, if in package.json the entry:
"proxy":"http://something" is present.
It doesn't show up if you delete that entry, and it doesn't show up with previous Node versions until 18.

Did you try recovering your dependencies?

$ yarn --version 1.22.18

Which terms did you search for in User Guide?

I searched for:
"react-script start fail" and for the error message:
"Invalid options object. Dev Server has been initialized using an options object that does not match the API schema."

Environment

Environment Info:

  current version of create-react-app: 5.0.1
  running from C:\Users\roralligator\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app

  System:
    OS: Windows 10 10.0.22000
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Binaries:
    Node: 18.0.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.18 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.6.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Spartan (44.22000.120.0), Chromium (100.0.1185.44)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    react: ^18.0.0 => 18.0.0
    react-dom: ^18.0.0 => 18.0.0
    react-scripts: ^5.0.0 => 5.0.0
  npmGlobalPackages:
    create-react-app: Not Found

( It says Windows 10, but it's actually under Window 11 )

Steps to reproduce

  1. Install Node version 18.0.0
  2. Initialize a cra app with yarn create react-app or npx create-react-app
  3. Edit package.json adding : `"proxy":"http://localhost:5000"
  4. Start the app with yarn start or npm run start

Expected behavior

The webpack development server should start within a few seconds.

Actual behavior

It throws an exception and exits:

$ react-scripts start
Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
 - options.allowedHosts[0] should be a non-empty string.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Reproducible demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions