You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Use Windows as OS.
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.
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
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.
Describe the bug
If the project is currently startet under Windows 7, the following error occurs (error is in german because of OS language):
To Reproduce
Additional context
Using
set PORT=3006 && react-scripts start
instead ofPORT=3006 react-scripts start
inpackage.json
fixes the problem for Windows, but might not work on UNIX Systems. Alternatively, environment variables could be stored in a.env
file instead inpackage.json
.See also the following discussion: https://stackoverflow.com/questions/40714583/how-to-specify-a-port-to-run-a-create-react-app-based-project
The text was updated successfully, but these errors were encountered: