# Unable to build a website from Github repository

**URL:** <https://answers.netlify.com/t/unable-to-build-a-website-from-github-repository/73678>\
**Category:** Support\
**Tags:** git, building\
**Created:** [August 18, 2022, 9:13am UTC](https://answers.netlify.com/t/unable-to-build-a-website-from-github-repository/73678 "2022-08-18T09:13:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vivka7](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/vivka7/32/40385_2.png) [@vivka7](https://answers.netlify.com/u/vivka7)\
**Post date:** [August 18, 2022, 9:13am UTC](https://answers.netlify.com/t/unable-to-build-a-website-from-github-repository/73678/1 "2022-08-18T09:13:44Z")

</div>

Hello,

I have tried most of the suggestions about this error codes: Command failed with exit code 127: npm run build and Failed during stage ‘building site’: Build script returned non-zero exit code: 2, but I can’t seem to make it work.  
I tried changing the build command to CI= npm run build, only build, webpack, etc.  
I added the CI false variable. No change. I don’t see where exactly is the problem, because there is no ERR message, please check the log below.

Issue building below:

12:05:07 PM: Build ready to start  
12:05:31 PM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)  
12:05:31 PM: build-image tag: v4.10.1  
12:05:31 PM: buildbot version: 4cffa5dc84445a450e8be6f710e2498d87994fae  
12:05:31 PM: Fetching cached dependencies  
12:05:31 PM: Failed to fetch cache, continuing with build  
12:05:31 PM: Starting to prepare the repo for build  
12:05:31 PM: No cached dependencies found. Cloning fresh repo  
12:05:31 PM: git clone [https://github.com/vivka7/travel-site](https://github.com/vivka7/travel-site)  
12:05:31 PM: Preparing Git Reference refs/heads/master  
12:05:32 PM: Parsing package.json dependencies  
12:05:32 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘docs’ versus ‘’ in the Netlify UI  
12:05:32 PM: Starting build script  
12:05:32 PM: Installing dependencies  
12:05:32 PM: Python version set to 2.7  
12:05:33 PM: Downloading and installing node v16.17.0…  
12:05:33 PM: Downloading [https://nodejs.org/dist/v16.17.0/node-v16.17.0-linux-x64.tar.xz](https://nodejs.org/dist/v16.17.0/node-v16.17.0-linux-x64.tar.xz)…  
12:05:33 PM: Computing checksum with sha256sum  
12:05:33 PM: Checksums matched!  
12:05:35 PM: Now using node v16.17.0 (npm v8.15.0)  
12:05:35 PM: Started restoring cached build plugins  
12:05:35 PM: Finished restoring cached build plugins  
12:05:35 PM: Attempting ruby version 2.7.2, read from environment  
12:05:36 PM: Using ruby version 2.7.2  
12:05:36 PM: Using PHP version 8.0  
12:05:36 PM: Started restoring cached go cache  
12:05:36 PM: Finished restoring cached go cache  
12:05:36 PM: Installing Go version 1.17 (requested 1.17)  
12:05:42 PM: unset GOOS;  
12:05:42 PM: unset GOARCH;  
12:05:42 PM: export GOROOT=‘/opt/buildhome/.gimme/versions/go1.17.linux.amd64’;  
12:05:42 PM: export PATH=“/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}”;  
12:05:42 PM: go version \>&2;  
12:05:42 PM: export GIMME\_ENV=“/opt/buildhome/.gimme/env/go1.17.linux.amd64.env”  
12:05:42 PM: go version go1.17 linux/amd64  
12:05:42 PM: Installing missing commands  
12:05:42 PM: Verify run directory  
12:05:43 PM: ​  
12:05:43 PM: ────────────────────────────────────────────────────────────────  
12:05:43 PM: Netlify Build  
12:05:43 PM: ────────────────────────────────────────────────────────────────  
12:05:43 PM: ​  
12:05:43 PM: ❯ Version  
12:05:43 PM: @netlify/build 27.11.5  
12:05:43 PM: ​  
12:05:43 PM: ❯ Flags  
12:05:43 PM: baseRelDir: true  
12:05:43 PM: buildId: 62fe00c374218e00b22660df  
12:05:43 PM: deployId: 62fe00c374218e00b22660e1  
12:05:43 PM: ​  
12:05:43 PM: ❯ Current directory  
12:05:43 PM: /opt/build/repo/docs  
12:05:43 PM: ​  
12:05:43 PM: ❯ Config file  
12:05:43 PM: No config file was defined: using default values.  
12:05:43 PM: ​  
12:05:43 PM: ❯ Context  
12:05:43 PM: production  
12:05:43 PM: ​  
12:05:43 PM: ────────────────────────────────────────────────────────────────  
12:05:43 PM: 1. Build command from Netlify app  
12:05:43 PM: ────────────────────────────────────────────────────────────────  
12:05:43 PM: ​  
12:05:43 PM: $ npm run build  
12:05:43 PM: \> test-repo@1.0.0 build  
12:05:43 PM: \> webpack  
12:05:43 PM: /tmp/build-032cadb6.sh: 1: webpack: not found  
12:05:43 PM: ​  
12:05:43 PM: ────────────────────────────────────────────────────────────────  
12:05:43 PM: “build.command” failed  
12:05:43 PM: ────────────────────────────────────────────────────────────────  
12:05:43 PM: ​  
12:05:43 PM: Error message  
12:05:43 PM: Command failed with exit code 127: npm run build ([Search results for '"non-zero exit code: 127"' - Netlify Support Forums](https://ntl.fyi/exit-code-127))  
12:05:43 PM: ​  
12:05:43 PM: Error location  
12:05:45 PM: Creating deploy upload records  
12:05:43 PM: In Build command from Netlify app:  
12:05:43 PM: npm run build  
12:05:43 PM: ​  
12:05:43 PM: Resolved config  
12:05:45 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](https://ntl.fyi/exit-code-2))  
12:05:43 PM: build:  
12:05:43 PM: base: /opt/build/repo/docs  
12:05:43 PM: command: npm run build  
12:05:43 PM: commandOrigin: ui  
12:05:43 PM: environment:  
12:05:43 PM: - CI  
12:05:43 PM: publish: /opt/build/repo/docs  
12:05:43 PM: publishOrigin: default  
12:05:44 PM: Caching artifacts  
12:05:44 PM: Started saving build plugins  
12:05:44 PM: Finished saving build plugins  
12:05:44 PM: Started saving pip cache  
12:05:44 PM: Finished saving pip cache  
12:05:44 PM: Started saving emacs cask dependencies  
12:05:44 PM: Finished saving emacs cask dependencies  
12:05:44 PM: Started saving maven dependencies  
12:05:44 PM: Finished saving maven dependencies  
12:05:44 PM: Started saving boot dependencies  
12:05:44 PM: Finished saving boot dependencies  
12:05:44 PM: Started saving rust rustup cache  
12:05:44 PM: Finished saving rust rustup cache  
12:05:44 PM: Started saving go dependencies  
12:05:44 PM: Finished saving go dependencies  
12:05:45 PM: Build failed due to a user error: Build script returned non-zero exit code: 2  
12:05:45 PM: Failing build: Failed to build site  
12:05:45 PM: Finished processing build request in 14.35767889s

PS. The website in Github is running and works: [https://vivka7.github.io/travel-site/](https://vivka7.github.io/travel-site/)

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![coelmay](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/coelmay/32/24427_2.png) [@coelmay](https://answers.netlify.com/u/coelmay)\
**Post date:** [August 18, 2022, 9:42am UTC](https://answers.netlify.com/t/unable-to-build-a-website-from-github-repository/73678/2 "2022-08-18T09:42:22Z")

</div>

Hi @vivka7

> [@vivka7](#):
>
> base: /opt/build/repo/docs

It would appear the `docs` directory contains a built site that requires no building, therefore there is no need for a build step. Set the _publish directory_ to `docs` and the site should deploy without issue.

---

<div class="post-metadata">

**Author:** ![vivka7](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/vivka7/32/40385_2.png) [@vivka7](https://answers.netlify.com/u/vivka7)\
**Post date:** [August 18, 2022, 10:29am UTC](https://answers.netlify.com/t/unable-to-build-a-website-from-github-repository/73678/4 "2022-08-18T10:29:41Z")

</div>

OMG thank you!  
Just removed the build command and it worked!

---

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [August 18, 2022, 9:28pm UTC](https://answers.netlify.com/t/unable-to-build-a-website-from-github-repository/73678/5 "2022-08-18T21:28:52Z")

</div>

Hey there, @vivka7 👋 glad everything is working for you now! Happy building 🚀

---

<div class="post-metadata">

**Author:** ![3P4R4](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/3p4r4/32/51819_2.png) [@3P4R4](https://answers.netlify.com/u/3P4R4)\
**Post date:** [June 16, 2023, 3:22pm UTC](https://answers.netlify.com/t/unable-to-build-a-website-from-github-repository/73678/6 "2023-06-16T15:22:48Z")

</div>

Me ha funcionado, gracias!
