How to set React app variables in NPM start script - reactjs

so the npm start in my package.json looks like this
"start": "REACT_APP_Environment=development react-scripts start",
This worked fine for previous developers on the project, possibly because they were on MacOS, that's not the case for me on windows, when I run I get
> REACT_APP_Environment=development react-scripts start
'REACT_APP_Environment' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! enterprise#0.1.0 start: `REACT_APP_Environment=development react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the enterprise#0.1.0 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! C:\Users\Omar\AppData\Roaming\npm-cache\_logs\2019-09-22T15_12_59_217Z-debug.log
I can fix this by removing the environment variable from the start script and running by the command set "REACT_APP_Environment=development" && npm start, but this is not convenient, how can I have it all included and work properly on windows in my start script? thanks

I would recommend checking out .env, seems like it might solve your problem
npmjs.com/package/dotenv

Related

npm start issue working on react and next .js

I just cloned code from a GitHub repository.
I tried to run it with the following command
'next' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nextjs#0.1.0 start: `next start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nextjs#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\DELL\AppData\Roaming\npm-cache\_logs\2021-10-12T12_27_53_876Z-debug.log
PS F:\REACT\projectnamme> node -v
v12.16.1
PS F:\REACT\projectnamme> npm -v
6.13.4
F:\REACT\projectnamme> create-react-app --version
3.4.1
first of all, you need to download your node_modules
you can use npm install or yarn install
then do npm start or yarn start in your terminal

ASP.NET CORE with REACT.js npm run build code 1

When the project is trying to be deployed, I get the following Error:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! s2cweb_react#0.1.0 build: react-scripts --expose-gc --max-old-space-size=8192 build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the s2cweb_react#0.1.0 build 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! /home/runner/.npm/_logs/2021-09-08T13_45_58_680Z-debug.log
/home/runner/work/MyProject/MyProjectApp/MyProjectApp.csproj(36,5): error MSB3073: The command "npm run build --prod" exited with code 1.
Error: Process completed with exit code 1.
I tried to change package.json as well as MyProjectApp.csproj but no luck. I Also tried without --prod but the same error persists. Please help me.

npm start problem: npm ERR! code ELIFECYCLE

I've got some problem with starting app by using 'npm start'. After create react files folder and using that command I can see:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! weatherapp#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the weatherapp#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I want to add that I've used react before. I was running code the same way but everything was good. What's the solution?
Make sure you are writing the npm start command to correct package where your package.json resides.
More likely it seems you don't have react script installed.
Can you try installing script with following command.
npm i react-scripts
This may solve your problem. Happy learning :)
Try to remove node_modules and package.log or yarn.lock file also. and run npm install again. Should solve your problem.

How can I disable npm run build errors?

I currently have an interesting error with npm run build and I don't know what's wrong. Is there a way to run the build with errors?
$ npm run build
> todoo#0.1.0 build D:\FitnessTracker
> tslint -p tslint.json && ./node_modules/.bin/tsc
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todoo#0.1.0 build: `tslint -p tslint.json && ./node_modules/.bin/tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todoo#0.1.0 build 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! C:\Users\raul.gimcojocaru\AppData\Roaming\npm-cache\_logs\2020-02-11T13_25_39_104Z-debug.log```
That project seems to expect an UNIX-style shell and you're on Windows.
You could try replacing the build script entry with just
"build": "tsc"
but there's no guarantees things will still work.

lwc-services is not recognized as an internal or external command

I am trying to run a hellow world app in LWC open source and after "npx create-lwc-app my-app" when I cd in the dir and run "npm run watch" I get the below error.
E:\Development\LWC\workspace\dev>npm run watch
> dev#0.0.0 watch E:\Development\LWC\workspace\dev
> lwc-services watch
'lwc-services' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dev#0.0.0 watch: `lwc-services watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dev#0.0.0 watch 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! C:\Users\ABC\AppData\Roaming\npm-cache\_logs\2019-12-24T16_31_47_970Z-debug.log
Have tried to install "npm install --global --production windows-build-tools" again, trierd to manually install npm i lwc-services -g but it has an error 'rollup-plugin2.02 is dprecated update your dependency' but I donot know if that is the issue here , reistalled the nmp but still not working.
You may try running 'npm run watch' after 'npm i' command.
The same issue has been asked here
I was instructed to do npm install -g lwc-services. There were several warnings, including "deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies."
That one seemed more serious than all the others, so I did npm install chokidar. That came in without any problems. Then I retried the previous command. I don't know if the Chokidar was such a big problem, but at least I was able to do the basic exercises and catch up with the rest of the class.

Resources