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.

3
  • Are you on Windows? Commented Sep 3, 2021 at 3:59
  • 2
    on.... which OS? because yeah, that's pretty true. For cross-platform environment setting, you probably want to prefix that using cross-env Commented Sep 3, 2021 at 3:59
  • Yes its on Windows Commented Sep 3, 2021 at 4:03

3 Answers 3

3

I am on Windows OS:

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

Sign up to request clarification or add additional context in comments.

3 Comments

This doesn't seem to be working for me. Has something changed?
nope i just use this and works fine for me, i think you have any other issues please check it on terminal or you can see other answer on my posts
It worked for me on Windows
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 :)

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.