Failing To Deploy Website With Netlify

So I’m trying to deploy my test app with netlify because it was recommended but I’m having issues with the build process. I even tried removing ‘window.location.pathname’ per the build logs but no luck. I’m sorry if this is a rookie question but this is like my 2nd time deploying a website, I’m just not sure what to do.

Netlify Link:

Netlify Build Logs:
4:38:56 PM: build-image version: ada486d80800a9a84b567366a5bfe2beab07892e (focal)
4:38:56 PM: buildbot version: ada486d80800a9a84b567366a5bfe2beab07892e
4:38:56 PM: Fetching cached dependencies
4:38:56 PM: Failed to fetch cache, continuing with build
4:38:56 PM: Starting to prepare the repo for build
4:38:56 PM: No cached dependencies found. Cloning fresh repo
4:38:56 PM: git clone --filter=blob:none GitHub - AaronBrinkley/Alone-Builder
4:38:56 PM: Preparing Git Reference refs/heads/main
4:38:57 PM: Parsing package.json dependencies
4:38:58 PM: Starting build script
4:38:58 PM: Installing dependencies
4:38:58 PM: Python version set to 2.7
4:38:58 PM: v16.19.0 is already installed.
4:38:59 PM: Now using node v16.19.0 (npm v8.19.3)
4:38:59 PM: Enabling Node.js Corepack
4:38:59 PM: Started restoring cached build plugins
4:38:59 PM: Finished restoring cached build plugins
4:38:59 PM: Attempting Ruby version 2.7.2, read from environment
4:38:59 PM: Using Ruby version 2.7.2
4:39:00 PM: Using PHP version 8.0
4:39:00 PM: Started restoring cached corepack dependencies
4:39:00 PM: mv: cannot move ‘/opt/build/cache/.node/corepack’ to ‘/opt/buildhome/.node/corepack’: No such file or directory
4:39:00 PM: Finished restoring cached corepack dependencies
4:39:00 PM: No npm workspaces detected
4:39:00 PM: Started restoring cached node modules
4:39:00 PM: Finished restoring cached node modules
4:39:00 PM: Bypassing sha validation. Running pre & post install scripts
4:39:00 PM: Installing npm packages using npm version 8.19.3
4:39:05 PM: npm WARN deprecated w3c-hr-time@1.0.2: Use your platform’s native performance.now() and performance.timeOrigin.npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: Array.prototype.sort() - JavaScript | MDN
4:39:05 PM: npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
4:39:05 PM: npm WARN deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
4:39:08 PM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
4:39:13 PM: added 1499 packages, and audited 1500 packages in 13s
4:39:13 PM: 232 packages are looking for funding
4:39:13 PM: run npm fund for details
4:39:13 PM: 6 high severity vulnerabilities
4:39:13 PM: To address all issues (including breaking changes), run:
4:39:13 PM: npm audit fix --force
4:39:13 PM: Run npm audit for details.
4:39:13 PM: npm packages installed
4:39:13 PM: Started restoring cached go cache
4:39:13 PM: Finished restoring cached go cache
4:39:13 PM: go version go1.19.5 linux/amd64
4:39:13 PM: Detected 1 framework(s)
4:39:13 PM: “create-react-app” at version “5.0.1”
4:39:13 PM: Installing missing commands
4:39:13 PM: Verify run directory
4:39:13 PM: Section completed: initializing
4:39:15 PM: ​
4:39:15 PM: Netlify Build
4:39:15 PM: ────────────────────────────────────────────────────────────────
4:39:15 PM: ​
4:39:15 PM: ❯ Version
4:39:15 PM: @netlify/build 29.5.3
4:39:15 PM: ​
4:39:15 PM: ❯ Flags
4:39:15 PM: baseRelDir: true
4:39:15 PM: buildId: 63dadbee20c89d0008aaf5ae
4:39:15 PM: deployId: 63dadbee20c89d0008aaf5b0
4:39:15 PM: ​
4:39:15 PM: ❯ Current directory
4:39:15 PM: /opt/build/repo
4:39:15 PM: ​
4:39:15 PM: ❯ Config file
4:39:15 PM: No config file was defined: using default values.
4:39:15 PM: ​
4:39:15 PM: ❯ Context
4:39:15 PM: production
4:39:15 PM: ​
4:39:15 PM: 1. Build command from Netlify app
4:39:15 PM: ────────────────────────────────────────────────────────────────
4:39:15 PM: ​
4:39:15 PM: $ npm run build
4:39:15 PM: > my-app@0.1.0 build
4:39:15 PM: > react-scripts build
4:39:16 PM: Creating an optimized production build…
4:39:23 PM:
4:39:23 PM: Treating warnings as errors because process.env.CI = true.
4:39:23 PM: Most CI servers set it automatically.
4:39:23 PM:
4:39:23 PM: Failed to compile.
4:39:23 PM:
4:39:23 PM: [eslint]
4:39:23 PM: src/App.js
4:39:23 PM: Line 11:9: ‘isPreviewingInBuilder’ is assigned a value but never used no-unused-vars
4:39:23 PM: Line 12:10: ‘notFound’ is assigned a value but never used no-unused-vars
4:39:23 PM: Line 28:6: React Hook useEffect has an unnecessary dependency: ‘window.location.pathname’. Either exclude it or remove the dependency array. Outer scope values like ‘window.location.pathname’ aren’t valid dependencies because mutating them doesn’t re-render the component react-hooks/exhaustive-deps
4:39:23 PM: ​
4:39:23 PM: “build.command” failed
4:39:23 PM: ────────────────────────────────────────────────────────────────
4:39:23 PM: ​
4:39:23 PM: Error message
4:39:23 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
4:39:23 PM: ​
4:39:23 PM: Error location
4:39:23 PM: In Build command from Netlify app:
4:39:23 PM: npm run build
4:39:23 PM: ​
4:39:23 PM: Resolved config
4:39:23 PM: build:
4:39:23 PM: command: npm run build
4:39:23 PM: commandOrigin: ui
4:39:23 PM: publish: /opt/build/repo/build
4:39:23 PM: publishOrigin: ui
4:39:23 PM: Caching artifacts
4:39:24 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
4:39:23 PM: Started saving node modules
4:39:23 PM: Finished saving node modules
4:39:23 PM: Started saving build plugins
4:39:23 PM: Finished saving build plugins
4:39:23 PM: Started saving pip cache
4:39:23 PM: Finished saving pip cache
4:39:23 PM: Started saving emacs cask dependencies
4:39:23 PM: Finished saving emacs cask dependencies
4:39:23 PM: Started saving maven dependencies
4:39:23 PM: Finished saving maven dependencies
4:39:23 PM: Started saving boot dependencies
4:39:23 PM: Finished saving boot dependencies
4:39:23 PM: Started saving rust rustup cache
4:39:23 PM: Finished saving rust rustup cache
4:39:23 PM: Started saving go dependencies
4:39:23 PM: Finished saving go dependencies
4:39:24 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:39:24 PM: Failing build: Failed to build site
4:39:24 PM: Finished processing build request in 28.187s

Builder content link

Builder public api key
b099763e816e428da045d2220629aa51

What are you trying to accomplish
Successful Compiling & Deploying

Code stack you are integrating Builder with
React.Js

Reproducible code example
import { useEffect, useState } from “react”;
import { BuilderComponent, builder, useIsPreviewing } from “@builder.io/react”;

// Put your API key here
builder.init(‘b099763e816e428da045d2220629aa51’);

// set whether you’re using the Visual Editor,
// whether there are changes,
// and render the content if found
export default function CatchAllRoute() {
const isPreviewingInBuilder = useIsPreviewing();
const [notFound, setNotFound] = useState(false);
const [content, setContent] = useState(null);

// get the page content from Builder
useEffect(() => {
async function fetchContent() {
const content = await builder
.get(“page”, {
url: window.location.pathname
})
.promise();

  setContent(content);
  setNotFound(!content);
}
fetchContent();

}, [window.location.pathname]);

// return the page when found
return (
<>

{content?.data.title}

{/* Render the Builder page */}

</>
);
}

Hi @Oscill19 , welcome to the forum! I believe this is occurring because the message Treating warnings as errors because process.env.CI = true is causing your build to fail. To resolve this you can either fix all the warnings in your app or disable the CI=true behavior in Netlify. You may find this article helpful:

1 Like

Thank you, I got it fixed. But now my page is showing up as blank when I see it deployed.

Hi @Oscill19 , can you share a link to the Netlify page? Are there any errors in the console?