React depoy with env variables

Hi I generally avoid netlify because my deploys always fail, but I need to learn! I’ve watched a few videos on deployment but I continue to fail. Help!
I am deploying through the netlify website.
failed site: https://xenodochial-bohr-63bf61.netlify.app/
deploy settings
Base directory: Not set
Build command: CI=npm run build
Publish directory: build/
Deploy log visibility: Logs are public
Builds: Active

I also have 7 different variables one example REACT_APP_API_KEY

deploy log
9:51:28 PM: Build ready to start
9:51:29 PM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
9:51:29 PM: build-image tag: v3.7.6
9:51:29 PM: buildbot version: 3934dc3e65fec0466cd25051c676f6e727c64ab1
9:51:29 PM: Building without cache
9:51:29 PM: Starting to prepare the repo for build
9:51:30 PM: No cached dependencies found. Cloning fresh repo
9:51:30 PM: git clone GitHub - primelos/gmail-clone
9:51:30 PM: Preparing Git Reference refs/heads/main
9:51:31 PM: Parsing package.json dependencies
9:51:32 PM: Different publish path detected, going to use the one specified in the Netlify
configuration file: β€˜build’ versus β€˜build/’ in the Netlify UI
9:51:32 PM: Starting build script
9:51:32 PM: Installing dependencies
9:51:32 PM: Python version set to 2.7
9:51:33 PM: v12.18.0 is already installed.
9:51:34 PM: Now using node v12.18.0 (npm v6.14.4)
9:51:34 PM: Started restoring cached build plugins
9:51:34 PM: Finished restoring cached build plugins
9:51:34 PM: Attempting ruby version 2.7.1, read from environment
9:51:35 PM: Using ruby version 2.7.1
9:51:35 PM: Using PHP version 5.6
9:51:35 PM: Started restoring cached go cache
9:51:35 PM: Finished restoring cached go cache
9:51:35 PM: go version go1.14.4 linux/amd64
9:51:35 PM: go version go1.14.4 linux/amd64
9:51:35 PM: Installing missing commands
9:51:35 PM: Verify run directory
9:51:37 PM: ​
9:51:37 PM:
────────────────────────────────────────────
────────────────────
9:51:37 PM: Netlify Build
9:51:37 PM:
────────────────────────────────────────────────────────────────
9:51:37 PM: ​
9:51:37 PM: ❯ Version
9:51:37 PM: @netlify/build 11.17.0
9:51:37 PM: ​
9:51:37 PM: ❯ Flags
9:51:37 PM: deployId: 609f53507b087d572cb8a06e
9:51:37 PM: ​
9:51:37 PM: ❯ Current directory
9:51:37 PM: /opt/build/repo
9:51:37 PM: ​
9:51:37 PM: ❯ Config file
9:51:37 PM: No config file was defined: using default values.
9:51:37 PM: ​
9:51:37 PM: ❯ Context
9:51:37 PM: production
9:51:37 PM: ​
9:51:37 PM: ────────────────────────────────────────────────────────────────
9:51:37 PM: 1. Build command from Netlify app
9:51:37 PM: ────────────────────────────────────────────────────────────────
9:51:37 PM: ​
9:51:37 PM: $ CI=npm run build
9:51:37 PM: bash: run: command not found
9:51:37 PM: ​
9:51:37 PM: ────────────────────────────────────────────────────────────────
9:51:37 PM: β€œbuild.command” failed
9:51:37 PM: ────────────────────────────────────────────────────────────────
9:51:37 PM: ​
9:51:37 PM: Error message
9:51:37 PM: Command failed with exit code 127: CI=npm run build
9:51:37 PM: ​
9:51:37 PM: Error location
9:51:37 PM: In Build command from Netlify app:
9:51:37 PM: CI=npm run build
9:51:37 PM: ​
9:51:37 PM: Resolved config
9:51:37 PM: build:
9:51:37 PM: command: CI=npm run build
9:51:37 PM: commandOrigin: ui
9:51:37 PM: environment:
9:51:37 PM: - REACT_APP_API_KEY
9:51:37 PM: - REACT_APP_APP_ID
9:51:37 PM: - REACT_APP_AUTH_DOMAIN
9:51:37 PM: - REACT_APP_MEASUREMENTID
9:51:37 PM: - REACT_APP_MESSAGING_SENDER_ID
9:51:37 PM: - REACT_APP_PROJECT_ID
9:51:37 PM: - REACT_APP_STORAGE_BUCKET
9:51:37 PM: publish: /opt/build/repo/build
9:51:37 PM: Caching artifacts
9:51:37 PM: Started saving build plugins
9:51:37 PM: Finished saving build plugins
9:51:37 PM: Started saving pip cache
9:51:38 PM: Finished saving pip cache
9:51:38 PM: Started saving emacs cask dependencies
9:51:38 PM: Finished saving emacs cask dependencies
9:51:38 PM: Started saving maven dependencies
9:51:38 PM: Finished saving maven dependencies
9:51:38 PM: Started saving boot dependencies
9:51:38 PM: Finished saving boot dependencies
9:51:38 PM: Started saving rust rustup cache
9:51:38 PM: Finished saving rust rustup cache
9:51:38 PM: Started saving go dependencies
9:51:38 PM: Finished saving go dependencies
9:51:40 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:51:40 PM: Creating deploy upload records
9:51:40 PM: Failing build: Failed to build site
9:51:40 PM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
9:51:40 PM: Finished processing build request in 10.813244429s

The command should be CI= npm run build. Notice the space.

1 Like

tried it and I believe its the same error. Below is the error after changing to CI= npm run build … I’m not sure what to try?

12:35:58 AM: Build ready to start

12:36:00 AM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
12:36:00 AM: build-image tag: v3.7.6
12:36:00 AM: buildbot version: 03c6f9d243f25556225c9548fcb276f97b8bf623
12:36:00 AM: Fetching cached dependencies
12:36:00 AM: Failed to fetch cache, continuing with build
12:36:00 AM: Starting to prepare the repo for build
12:36:00 AM: No cached dependencies found. Cloning fresh repo
12:36:00 AM: git clone GitHub - primelos/gmail-clone
12:36:01 AM: Preparing Git Reference refs/heads/main
12:36:02 AM: Parsing package.json dependencies
12:36:03 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: β€˜build’ versus β€˜build/’ in the Netlify UI
12:36:03 AM: Starting build script
12:36:03 AM: Installing dependencies
12:36:03 AM: Python version set to 2.7
12:36:04 AM: v12.18.0 is already installed.
12:36:05 AM: Now using node v12.18.0 (npm v6.14.4)
12:36:05 AM: Started restoring cached build plugins
12:36:05 AM: Finished restoring cached build plugins
12:36:05 AM: Attempting ruby version 2.7.1, read from environment
12:36:06 AM: Using ruby version 2.7.1
12:36:07 AM: Using PHP version 5.6
12:36:07 AM: Started restoring cached go cache
12:36:07 AM: Finished restoring cached go cache
12:36:07 AM: go version go1.14.4 linux/amd64
12:36:07 AM: go version go1.14.4 linux/amd64
12:36:07 AM: Installing missing commands
12:36:07 AM: Verify run directory
12:36:09 AM: ​
12:36:09 AM: ────────────────────────────────────────────────────────────────
12:36:09 AM: Netlify Build
12:36:09 AM: ────────────────────────────────────────────────────────────────
12:36:09 AM: ​
12:36:09 AM: ❯ Version
12:36:09 AM: @netlify/build 11.17.2
12:36:09 AM: ​
12:36:09 AM: ❯ Flags
12:36:09 AM: deployId: 60a36e5efb3034af27545e1f
12:36:09 AM: ​
12:36:09 AM: ❯ Current directory
12:36:09 AM: /opt/build/repo
12:36:09 AM: ​
12:36:09 AM: ❯ Config file
12:36:09 AM: No config file was defined: using default values.
12:36:09 AM: ​
12:36:09 AM: ❯ Context
12:36:09 AM: production
12:36:09 AM: ​
12:36:09 AM: ────────────────────────────────────────────────────────────────
12:36:09 AM: 1. Build command from Netlify app
12:36:09 AM: ────────────────────────────────────────────────────────────────
12:36:09 AM: ​
12:36:09 AM: $ CI= npm run build
12:36:09 AM: npm ERR! code ENOENT
12:36:09 AM: npm ERR! syscall open
12:36:09 AM: npm ERR! path /opt/build/repo/package.json
12:36:09 AM: npm ERR! errno -2
12:36:09 AM: npm ERR! enoent ENOENT: no such file or directory, open β€˜/opt/build/repo/package.json’
12:36:09 AM: npm ERR! enoent This is related to npm not being able to find a file.
12:36:09 AM: npm ERR! enoent
12:36:09 AM: npm ERR! A complete log of this run can be found in:
12:36:09 AM: npm ERR! /opt/buildhome/.npm/_logs/2021-05-18T07_36_09_393Z-debug.log
12:36:09 AM: ​
12:36:09 AM: ────────────────────────────────────────────────────────────────
12:36:09 AM: β€œbuild.command” failed
12:36:09 AM: ────────────────────────────────────────────────────────────────
12:36:09 AM: ​
12:36:09 AM: Error message
12:36:09 AM: Command failed with exit code 254: CI= npm run build
12:36:09 AM: ​
12:36:09 AM: Error location
12:36:09 AM: In Build command from Netlify app:
12:36:09 AM: CI= npm run build
12:36:09 AM: ​
12:36:09 AM: Resolved config
12:36:09 AM: build:
12:36:09 AM: command: CI= npm run build
12:36:09 AM: commandOrigin: ui
12:36:09 AM: environment:
12:36:09 AM: - REACT_APP_API_KEY
12:36:09 AM: - REACT_APP_APP_ID
12:36:09 AM: - REACT_APP_AUTH_DOMAIN
12:36:09 AM: - REACT_APP_MEASUREMENTID
12:36:09 AM: - REACT_APP_MESSAGING_SENDER_ID
12:36:09 AM: - REACT_APP_PROJECT_ID
12:36:09 AM: - REACT_APP_STORAGE_BUCKET
12:36:09 AM: publish: /opt/build/repo/build
12:36:09 AM: Caching artifacts
12:36:09 AM: Started saving build plugins
12:36:09 AM: Finished saving build plugins
12:36:09 AM: Started saving pip cache
12:36:09 AM: Finished saving pip cache
12:36:09 AM: Started saving emacs cask dependencies
12:36:10 AM: Finished saving emacs cask dependencies
12:36:10 AM: Started saving maven dependencies
12:36:10 AM: Finished saving maven dependencies
12:36:10 AM: Started saving boot dependencies
12:36:10 AM: Finished saving boot dependencies
12:36:10 AM: Started saving rust rustup cache
12:36:10 AM: Finished saving rust rustup cache
12:36:10 AM: Started saving go dependencies
12:36:10 AM: Finished saving go dependencies
12:36:12 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:36:12 AM: Creating deploy upload records
12:36:12 AM: Failing build: Failed to build site
12:36:12 AM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
12:36:12 AM: Finished processing build request in 12.659149964s

It’s definitely not the same error. First was command not found, now it says package.json not found. You’ve probably not set gmail as your base path.

1 Like

Got it thank you! Still had another hiccup but I figured it out! I am working on another project and will deploy to netlify when I am done to practice

1 Like