'Problem with deploying a React app to Azure pipelines

I have recently updated my React.js app to the version 17.0.2 (of React). App worked fine locally, however when I have tried to deploy it after changes to Azure, I have gotten a 404 error. When I looked into the logs of pipeline build, I have noticed following error for npm install and build part of deployment:

2022-03-30T07:48:26.6297187Z ##[section]Starting: npm install and build
2022-03-30T07:48:26.6304141Z ==============================================================================
2022-03-30T07:48:26.6304446Z Task         : Command line
2022-03-30T07:48:26.6304754Z Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2022-03-30T07:48:26.6305042Z Version      : 2.201.1
2022-03-30T07:48:26.6305248Z Author       : Microsoft Corporation
2022-03-30T07:48:26.6305566Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2022-03-30T07:48:26.6305936Z ==============================================================================
2022-03-30T07:48:26.7615293Z Generating script.
2022-03-30T07:48:26.7618118Z ========================== Starting Command Output ===========================
2022-03-30T07:48:26.7639271Z [command]/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/940428dd-e14e-4b02-9656-d124e073f2e7.sh
2022-03-30T07:48:26.7696372Z ~/work/1/s/Sign-Off.UI/ClientApp/src ~/work/1/s
2022-03-30T07:48:27.4938139Z npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
2022-03-30T07:49:03.6068599Z 
2022-03-30T07:49:03.6073418Z > [email protected] postinstall /home/vsts/work/1/s/Sign-Off.UI/ClientApp/node_modules/core-js
2022-03-30T07:49:03.6074808Z > node -e "try{require('./postinstall')}catch(e){}"
2022-03-30T07:49:03.6075339Z 
2022-03-30T07:49:03.6732516Z [96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m
2022-03-30T07:49:03.6741124Z 
2022-03-30T07:49:03.6743826Z [96mThe project needs your help! Please consider supporting of core-js on Open Collective or Patreon: [0m
2022-03-30T07:49:03.6745448Z [96m>[94m https://opencollective.com/core-js [0m
2022-03-30T07:49:03.6760976Z [96m>[94m https://www.patreon.com/zloirock [0m
2022-03-30T07:49:03.6763038Z 
2022-03-30T07:49:03.6765302Z [96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m
2022-03-30T07:49:03.6766203Z 
2022-03-30T07:49:03.6887513Z 
2022-03-30T07:49:03.6890250Z > [email protected] postinstall /home/vsts/work/1/s/Sign-Off.UI/ClientApp/node_modules/core-js-pure
2022-03-30T07:49:03.6891639Z > node -e "try{require('./postinstall')}catch(e){}"
2022-03-30T07:49:03.6892308Z 
2022-03-30T07:49:03.7730793Z [96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m
2022-03-30T07:49:03.7731533Z 
2022-03-30T07:49:03.7738824Z [96mThe project needs your help! Please consider supporting of core-js:[0m
2022-03-30T07:49:03.7776462Z [96m>[94m https://opencollective.com/core-js [0m
2022-03-30T07:49:03.7777024Z [96m>[94m https://patreon.com/zloirock [0m
2022-03-30T07:49:03.7777467Z [96m>[94m https://paypal.me/zloirock [0m
2022-03-30T07:49:03.7777978Z [96m>[94m bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz [0m
2022-03-30T07:49:03.7778206Z 
2022-03-30T07:49:03.7778735Z [96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m
2022-03-30T07:49:03.7778979Z 
2022-03-30T07:49:03.9813624Z 
2022-03-30T07:49:03.9816354Z > [email protected] postinstall /home/vsts/work/1/s/Sign-Off.UI/ClientApp/node_modules/react-app-polyfill/node_modules/core-js
2022-03-30T07:49:03.9853757Z > node -e "try{require('./postinstall')}catch(e){}"
2022-03-30T07:49:03.9880558Z 
2022-03-30T07:49:05.2365372Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
2022-03-30T07:49:05.2366895Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2022-03-30T07:49:05.2391815Z 
2022-03-30T07:49:05.2428775Z added 1715 packages from 840 contributors and audited 1691 packages in 37.796s
2022-03-30T07:49:06.1082783Z 
2022-03-30T07:49:06.1084449Z 184 packages are looking for funding
2022-03-30T07:49:06.1085803Z   run `npm fund` for details
2022-03-30T07:49:06.1086338Z 
2022-03-30T07:49:06.1087425Z found 11 vulnerabilities (8 moderate, 3 high)
2022-03-30T07:49:06.1087931Z   run `npm audit fix` to fix them, or `npm audit` for details
2022-03-30T07:49:06.3558927Z 
2022-03-30T07:49:06.3560572Z > [email protected] build /home/vsts/work/1/s/Sign-Off.UI/ClientApp
2022-03-30T07:49:06.3571267Z > react-scripts build
2022-03-30T07:49:06.3571429Z 
2022-03-30T07:49:07.6812827Z Creating an optimized production build...
2022-03-30T07:49:55.8229001Z Failed to compile.
2022-03-30T07:49:55.8229319Z 
2022-03-30T07:49:55.8235260Z src/api/ProjectData.js
2022-03-30T07:49:55.8256231Z   Line 66:3:  'state' is not defined  no-undef
2022-03-30T07:49:55.8256486Z 
2022-03-30T07:49:55.8257069Z src/components/create-project/AddFileInput.js
2022-03-30T07:49:55.8257600Z   Line 9:3:    'state' is not defined         no-undef
2022-03-30T07:49:55.8258117Z   Line 11:3:   'getBase64' is not defined     no-undef
2022-03-30T07:49:55.8258634Z   Line 45:10:  'handleUpload' is not defined  no-undef
2022-03-30T07:49:55.8258815Z 
2022-03-30T07:49:55.8259067Z src/pages/Project/ProjectDetails.js
2022-03-30T07:49:55.8259514Z   Line 222:5:  'state' is not defined  no-undef
2022-03-30T07:49:55.8259681Z 
2022-03-30T07:49:55.8259949Z Search for the keywords to learn more about each error.
2022-03-30T07:49:55.8260111Z 
2022-03-30T07:49:55.8260184Z 
2022-03-30T07:49:55.8738642Z npm ERR! code ELIFECYCLE
2022-03-30T07:49:55.8739065Z npm ERR! errno 1
2022-03-30T07:49:55.8777067Z npm ERR! [email protected] build: `react-scripts build`
2022-03-30T07:49:55.8777433Z npm ERR! Exit status 1
2022-03-30T07:49:55.8777699Z npm ERR! 
2022-03-30T07:49:55.8777969Z npm ERR! Failed at the [email protected] build script.
2022-03-30T07:49:55.8778404Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-03-30T07:49:55.8894228Z 
2022-03-30T07:49:55.8894668Z npm ERR! A complete log of this run can be found in:
2022-03-30T07:49:55.8897422Z npm ERR!     /home/vsts/.npm/_logs/2022-03-30T07_49_55_877Z-debug.log
2022-03-30T07:49:55.8994167Z ~/work/1/s
2022-03-30T07:49:55.9097704Z ##[section]Finishing: npm install and build

The app has been hosted on Azure and deployed through Pipelines for many months without a problem. Yes, there are a few errors listed in the included log (such as "'state' is not defined"), but they make no sense as they are very basic errors which should also be the problem locally, whereas the app runs flawlessly there. The NodeJS version I am using on pipelines is 14.18.1. Does anybody know how to solve this problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source