Home
Support Forums

Failed during stage 'building site': Build script returned non-zero exit code: 1 (Error)

It worked fine locally but i couldn’t deploy in netlify. I’ve tried both npm run build and CI= npm run build but still it shows the same error. What should I do?

3:07:56 PM: Build ready to start
3:07:59 PM: build-image version: 2cee85eb7f808bf3b6e87378c5307f9411f0a332
3:07:59 PM: build-image tag: v3.8.0
3:07:59 PM: buildbot version: 02abb8b68968c22860647fd09d700bee67acb65f
3:07:59 PM: Building without cache
3:07:59 PM: Starting to prepare the repo for build
3:07:59 PM: No cached dependencies found. Cloning fresh repo
3:07:59 PM: git clone GitHub - shanriyasp/My-Shopping-Site: An Online Book Store
3:08:00 PM: Preparing Git Reference refs/heads/main
3:08:00 PM: Parsing package.json dependencies
3:08:01 PM: Starting build script
3:08:01 PM: Installing dependencies
3:08:01 PM: Python version set to 2.7
3:08:02 PM: v12.18.0 is already installed.
3:08:03 PM: Now using node v12.18.0 (npm v6.14.4)
3:08:03 PM: Started restoring cached build plugins
3:08:03 PM: Finished restoring cached build plugins
3:08:03 PM: Attempting ruby version 2.7.2, read from environment
3:08:05 PM: Using ruby version 2.7.2
3:08:05 PM: Using PHP version 5.6
3:08:05 PM: Started restoring cached node modules
3:08:05 PM: Finished restoring cached node modules
3:08:05 PM: Installing NPM modules using NPM version 6.14.4
3:08:06 PM: npm ERR! Unexpected token { in JSON at position 695038 while parsing near ‘…Z2Q=="npm ERR! }
3:08:06 PM: npm ERR! }
3:08:06 PM: npm ERR! }
3:08:06 PM: npm ERR!
3:08:06 PM: npm ERR! {
3:08:06 PM: npm ERR! “requires”: true…’
3:08:06 PM: npm ERR! A complete log of this run can be found in:
3:08:06 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-07-08T09_38_06_471Z-debug.log
3:08:06 PM: Error during NPM install
3:08:06 PM: Build was terminated: Build script returned non-zero exit code: 1
3:08:06 PM: Creating deploy upload records
3:08:06 PM: Failing build: Failed to build site
3:08:06 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1
3:08:06 PM: Finished processing build request in 7.547324492s

Blockquote

Hi @shanriyasp,

Could you try deleting package-lock.json and then clear cache and deploy?

I tried doing that but still it shows the same error

6:38:03 PM: Build ready to start
6:38:04 PM: build-image version: 2cee85eb7f808bf3b6e87378c5307f9411f0a332
6:38:04 PM: build-image tag: v3.8.0
6:38:04 PM: buildbot version: 02abb8b68968c22860647fd09d700bee67acb65f
6:38:04 PM: Building without cache
6:38:04 PM: Starting to prepare the repo for build
6:38:05 PM: No cached dependencies found. Cloning fresh repo
6:38:05 PM: git clone GitHub - shanriyasp/My-Shopping-Site: An Online Book Store
6:38:06 PM: Preparing Git Reference refs/heads/main
6:38:06 PM: Parsing package.json dependencies
6:38:07 PM: Starting build script
6:38:07 PM: Installing dependencies
6:38:07 PM: Python version set to 2.7
6:38:08 PM: v12.18.0 is already installed.
6:38:08 PM: Now using node v12.18.0 (npm v6.14.4)
6:38:08 PM: Started restoring cached build plugins
6:38:08 PM: Finished restoring cached build plugins
6:38:08 PM: Attempting ruby version 2.7.2, read from environment
6:38:09 PM: Using ruby version 2.7.2
6:38:10 PM: Using PHP version 5.6
6:38:10 PM: Started restoring cached node modules
6:38:10 PM: Finished restoring cached node modules
6:38:10 PM: Installing NPM modules using NPM version 6.14.4
6:38:10 PM: npm ERR! Unexpected token { in JSON at position 695038 while parsing near ‘…Z2Q=="npm ERR! }
6:38:10 PM: npm ERR! }
6:38:10 PM: npm ERR! }
6:38:10 PM: npm ERR!
6:38:10 PM: npm ERR! {
6:38:10 PM: npm ERR! “requires”: true…’
6:38:10 PM: npm ERR! A complete log of this run can be found in:
6:38:10 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-07-08T13_08_10_912Z-debug.log
6:38:10 PM: Error during NPM install
6:38:10 PM: Build was terminated: Build script returned non-zero exit code: 1
6:38:10 PM: Creating deploy upload records
6:38:11 PM: Failing build: Failed to build site
6:38:11 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1

It looks like package-lock.json still exists in the repo:

I’ve been stuck up with this for the past week not knowing that the changes I’ve committed in local github didn’t effect in the web even though I’ve committed the changes to main in local. The error is resolved and I’ve created my page. Thank You So Much !! You are a Saviour : +1: :slightly_smiling_face: