0

When I run yarn dev It shows this following error on command prompt:

yarn run v1.22.11
$ PORT=3005 next dev
'PORT' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

My package.json is like:

"scripts": {
    "dev": "PORT=3005 next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "test": "jest"
  },

How to fix this error?

Note: I am using Windows OS.

juliomalves
  • 42,130
  • 20
  • 150
  • 146
Shawn
  • 1,232
  • 1
  • 14
  • 44

3 Answers3

1

I am on Windows OS:

And fixed this using "dev": "next dev -p 3005"

Shawn
  • 1,232
  • 1
  • 14
  • 44
0

Change your package.json:

"scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "test": "jest"
  },

Then create a .env file in your project directory, and set this:

'.env' file

PORT=3005

then run your project :)

Pranava Mohan
  • 533
  • 2
  • 8
  • 18
0

in package.json write "start": "react-scripts start", instead of this "start": "PORT=3001 react-scripts start",