Home
Support Forums

I tried to deploy my app this error coming help ty

───────────────────────────────────────────────────────
5:03:04 AM: ​
5:03:04 AM: $ npm run build
5:03:04 AM: > crypter@0.1.0 build
5:03:04 AM: > react-scripts build
5:03:06 AM: Creating an optimized production build…
5:03:24 AM:
5:03:24 AM: Treating warnings as errors because process.env.CI = true.
5:03:24 AM: Most CI servers set it automatically.
5:03:24 AM:
5:03:24 AM: Failed to compile.
5:03:24 AM:
5:03:24 AM: src/component/MultiItemCarousel/MultiItemSlider/Slider.js
5:03:24 AM: Line 1:17: ‘useState’ is defined but never used no-unused-vars
5:03:24 AM: src/component/MultiItemCarousel/SectionSixCard/SectionSixMapped.js
5:03:24 AM: Line 8:9: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
5:03:24 AM: src/component/SectionSix/SectionSixCard/SectionSixData.js
5:03:24 AM: Line 8:8: ‘DiscoveryWade’ is defined but never used no-unused-vars
5:03:24 AM: src/component/SectionSix/SectionSixCard/SectionSixMapped.js
5:03:24 AM: Line 8:9: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
5:03:24 AM: src/component/SectionThree/SlickCard/SlickCard.js
5:03:24 AM: Line 3:8: ‘Wade’ is defined but never used no-unused-vars
5:03:24 AM: src/component/SectionThree/SlickCard/SlickCardMapped.js
5:03:24 AM: Line 2:8: ‘SlickData’ is defined but never used no-unused-vars
5:03:24 AM: ​
5:03:24 AM: ────────────────────────────────────────────────────────────────
5:03:24 AM: “build.command” failed
5:03:24 AM: ────────────────────────────────────────────────────────────────
5:03:24 AM: ​
5:03:24 AM: Error message
5:03:24 AM: Command failed with exit code 1: npm run build
5:03:24 AM: ​
5:03:24 AM: Error location
5:03:24 AM: In Build command from Netlify app:
5:03:24 AM: npm run build
5:03:24 AM: ​
5:03:24 AM: Resolved config
5:03:24 AM: build:
5:03:24 AM: command: npm run build
5:03:24 AM: commandOrigin: ui
5:03:24 AM: publish: /opt/build/repo/build
5:03:24 AM: publishOrigin: ui
5:03:24 AM: Caching artifacts
5:03:24 AM: Started saving node modules
5:03:24 AM: Finished saving node modules
5:03:24 AM: Started saving build plugins
5:03:24 AM: Finished saving build plugins
5:03:24 AM: Started saving pip cache
5:03:24 AM: Finished saving pip cache
5:03:24 AM: Started saving emacs cask dependencies
5:03:24 AM: Finished saving emacs cask dependencies
5:03:24 AM: Started saving maven dependencies
5:03:24 AM: Finished saving maven dependencies
5:03:24 AM: Started saving boot dependencies
5:03:24 AM: Finished saving boot dependencies
5:03:24 AM: Started saving rust rustup cache
5:03:24 AM: Finished saving rust rustup cache
5:03:24 AM: Started saving go dependencies
5:03:24 AM: Finished saving go dependencies
5:03:26 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:03:26 AM: Creating deploy upload records
5:03:26 AM: Failing build: Failed to build site
5:03:26 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
5:03:26 AM: Finished processing build request in 1m39.403141196s

Hi @noumankhan

Due to CI = true by default, the warnings below are treated as errors.

To avoid warnings (and thus errors), ensure you are defining only those variables that are used, and ensure all properties (such as alt="" in an <img> tag) are included. This will mean better code, which is more standards compliant.

The other option is to ignore such warnings and thus potentially have poorer quality, non-standards compliant, code by changing the build command to CI='' npm run build. This sets CI to false and thus no longer treats warnings as errors.

I hope you choose the former and not the latter.