Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows does not recognize the "PORT=3006" command in package.json #100

Closed
murezzda opened this issue Feb 15, 2019 · 4 comments
Closed

Windows does not recognize the "PORT=3006" command in package.json #100

murezzda opened this issue Feb 15, 2019 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@murezzda
Copy link
Contributor

Describe the bug
If the project is currently startet under Windows 7, the following error occurs (error is in german because of OS language):

Der Befehl "PORT" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @bbc/react-transcript-editor@0.2.12 start: "PORT=3006 react-scripts start"
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @bbc/react-transcript-editor@0.2.12 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! [path_to_log_file]

To Reproduce

  1. Use Windows as OS.
  2. Run 'npm start' in the project folder.

Additional context
Using set PORT=3006 && react-scripts start instead of PORT=3006 react-scripts start in package.json fixes the problem for Windows, but might not work on UNIX Systems. Alternatively, environment variables could be stored in a .env file instead in package.json.

See also the following discussion: https://stackoverflow.com/questions/40714583/how-to-specify-a-port-to-run-a-create-react-app-based-project

@murezzda murezzda added the bug Something isn't working label Feb 15, 2019
@pietrop
Copy link
Contributor

pietrop commented Feb 15, 2019

Thanks @murezzda , a quick fix I can think of is to go back to the default 3000 port, would that work for you?
and spare any fiddly cross platform configuration at this stage

@murezzda
Copy link
Contributor Author

That would also be ok for me. Thanks!

@pietrop
Copy link
Contributor

pietrop commented Feb 15, 2019

addressed in PR #101

@pietrop pietrop closed this as completed Feb 20, 2019
@pietrop
Copy link
Contributor

pietrop commented Mar 2, 2019

Just making a note, if we ever need to revisit this, I found that cross-env (mentioned in yarn workspaces) could be used for this.

Run scripts that set and use environment variables across platforms

Most Windows command prompts will choke when you set environment variables with NODE_ENV=production like that. (The exception is Bash on Windows, which uses native Bash.) Similarly, there's a difference in how windows and POSIX commands utilize environment variables. With POSIX, you use: $ENV_VAR and on windows you use %ENV_VAR%.

cross-env makes it so you can have a single command without worrying about setting or using the environment variable properly for the platform. Just set it like you would if it's running on a POSIX system, and cross-env will take care of setting it properly.

see their README for more info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants