I'm able to start the app locally but when attempting to deploy the site, I'm getting the following error log
Between the Failed to compile. text and npm ERR! code ELIFECYCLE there seems to be a couple warnings i.e. use of == instead of === and unused variables.
Build command npm run build
Publish directory tried both build and build/
Is that what's really causing the failure to deploy or is it something else?
Remove the warnings from your code. That's why the build is failing. You have multiple warnings as shown in this console output. Their CI pipeline is treating warnings as errors because process.env.CI is set to true.
Related
I've been getting some syntax errors and i've removed all the code in the file, but the react app is showing the same compile errors and there is no use of npm run build even the build fails because of the syntax error which i removed already. What might be the problem?
I had previously executed npm start without any errors on the exact same code. Since the last time I had executed it without any errors, I had made no changes to the files. But just a day later, the same code suddenly gave this error:
> client#0.1.0 start
> react-scripts start
Cannot use import statement outside a module
I can't understand why this happened. However, npm run build compiles without any errors and generates the build properly. So I don't think it is some issue with the code.
Further, I ran npm install once again, I found that there were some vulnerabilities:
added 684 packages, removed 193 packages, changed 411 packages, and audited 1873 packages in 2m
153 packages are looking for funding
run `npm fund` for details
32 vulnerabilities (19 moderate, 12 high, 1 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
So, following the instruction I used npm audit fix --force and I saw it updated react-scripts to version 5.0.0 . This suddenly solved the previous error and the code compiled without errors after this, however, now I faced another problem.
On visiting localhost:3000 it showed localhost refused to connect, even though my terminal showed that the code was compiled successfully.
This is the project in which I encountered the error: https://github.com/DevRish/martcart.
I have also opened an issue regarding this: https://github.com/DevRish/martcart/issues/1
I am confused about two things here. Firstly, with react-scripts version 4.0.3, why is build compiling without errors but development environment giving error? Secondly, even when react-scripts version 5.0.0 compiles the code successfully, why does localhost:3000 show 'refused to connect' ?
Update: After removing the setupProxy.js file, it works fine.
I added the proxy attribute in the package.json file to achieve the proxying functionality.
I have a project based on create-react-app and when I run it locally I get zero ESlint warnings or errors, that's when running npm start and npm build.
When I try to publish to Azure using GitHub Actions I get loads of errors on build, errors such as "no-unused-vars", "react-hooks/exhaustive-deps" etc.
I can see this is because GitHub Actions is turning warnings into errors because of the following...
Treating warnings as errors because process.env.CI = true.
Most CI servers set it automatically.
I'd like to be able to fix all of these errors but when I build locally it doesn't show warnings. I've tried various things like adding a .env file with CI = true, trying to set the ESlint config etc but nothing I do will make it fail when I run or build the site locally.
I am trying to start up a react app. After cloning the code from github, running yarn install I ran yarn start and got the following error:
yarn run v1.22.10
$ cross-env HTTPS=true react-scripts start
Unexpected identifier
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The authors of the app don't know what might be wrong (it's working for them). I tried creating another app with create react app and that started up fine for me. I am not sure where to start looking as there is no indication as to where the "unexpected identifier" might be located or what it might be. Any ideas on what I might want to check or try? I am on MacOS Catalina.
I figured it out eventually. I tried running build and it failed on syntax error in one of the .js files (a missing comma). Once that was fixed the start ran too. If the start command returned the same informative error the build did it would have saved me hours :)
Netlify and Vercel both would refuse to deploy if there is a tiny warning, with the error message:
Treating warnings as errors because process.env.CI = true.
and so the solution is:
How to prevent Netlify from treating warnings as errors because process.env.CI = true?
override the build command with:
CI=false npm run build
or
CI= npm run build
what do they mean? Aren't they just setting the environment variable CI and not really a "command"?
Just like the usage of
GREP_COLOR="1;32" grep foo bar.txt
so
CI=false npm run build
is to mean, set the environment variable CI to false and then under such condition, run the command npm run build.
If you use webpack like me, you need add commands above.
I hope that will be solution of your problems :)