Home > database >  problems with deploying react project on netlify
problems with deploying react project on netlify

Time:06-29

netlify giving me error cant figure it out. I tried CI= npm run build

CodePudding user response:

Have you deployed a previous version of this project to netlify. If so, it's possible that you may want to deploy this as a new project after deleting the original. If not, Netlify has deployment docs, you could look through. Hope this helps!

CodePudding user response:

This errors happened whith node version 16 and later, apparently. The reason is related to package-lock.json module versions. If you do not have a package-lock.json in your repo, the dependency changes every time you build. Some modules might cause dependency errors.

Netlify support suggests you either use a lower version of node when deploying (Just set node version as environmental veriables e.g The NODE_VERSION environment variable, or a .node-version / .nvmrc file.) or use --force when installing the node modules

The error is a peer dependency conflict relating to versions of react, which provides guidance on how you can attempt to resolve it:

Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

It suggests you can run npm install --force or npm install --legacy-peer-deps.

To do this on Netlify you can use the NPM_FLAGS environment variable.

NPM_FLAGS: used to indicate the flags to pass to the npm install command.

Setting it to either --force or --legacy-peer-deps depending on your preference.

To add environmental variables there is a section in your project settings named Envrionment variables

Please, have a look at the Netlify forum: https://answers.netlify.com/t/deploy-failed-today-build-was-terminated-build-script-returned-non-zero-exit-code-1/64450

  • Related