Website not deploying, using npm build

I am trying to deploy my website using netlify. My index.html page is not in the root folder, instead its in the dist folder. I have set the publish directory to dist, however I am still getting an error. i have also added npm run build as the build command, and still nothing.

My deploy log:

4:44:29 PM: Build ready to start
4:44:31 PM: build-image version: 6dfe19d15f524c85d6f9bf7df9fb30b0a9f0a61a
4:44:31 PM: build-image tag: v3.3.10
4:44:31 PM: buildbot version: 6bb3f784302b4ad90de13035b247a363a8bee34a
4:44:31 PM: Fetching cached dependencies
4:44:31 PM: Starting to download cache of 1.3MB
4:44:31 PM: Finished downloading cache in 121.664123ms
4:44:31 PM: Starting to extract cache
4:44:31 PM: Finished extracting cache in 20.859356ms
4:44:31 PM: Finished fetching cache in 143.358671ms
4:44:31 PM: Starting to prepare the repo for build
4:44:32 PM: Preparing Git Reference refs/heads/master
4:44:32 PM: Starting build script
4:44:32 PM: Installing dependencies
4:44:33 PM: v10.20.1 is already installed.
4:44:34 PM: Now using node v10.20.1 (npm v6.14.4)
4:44:34 PM: Attempting ruby version 2.6.2, read from environment
4:44:36 PM: Using ruby version 2.6.2
4:44:36 PM: Using PHP version 5.6
4:44:36 PM: 5.2 is already installed.
4:44:36 PM: Using Swift version 5.2
4:44:36 PM: Started restoring cached node modules
4:44:36 PM: Finished restoring cached node modules
4:44:36 PM: Installing NPM modules using NPM version 6.14.4
4:44:41 PM: > node-sass@4.14.1 install /opt/build/repo/node_modules/node-sass
4:44:41 PM: > node scripts/install.js
4:44:41 PM: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-64_binding.node
4:44:42 PM: Download complete
4:44:42 PM: Binary saved to /opt/build/repo/node_modules/node-sass/vendor/linux-x64-64/binding.node
4:44:42 PM: Caching binary to /opt/buildhome/.npm/node-sass/4.14.1/linux-x64-64_binding.node
4:44:42 PM: > node-sass@4.14.1 postinstall /opt/build/repo/node_modules/node-sass
4:44:42 PM: > node scripts/build.js
4:44:42 PM: Binary found at /opt/build/repo/node_modules/node-sass/vendor/linux-x64-64/binding.node
4:44:42 PM: Testing binary
4:44:42 PM: Binary is fine
4:44:42 PM: npm
4:44:42 PM: WARN portfolio2020sass@1.0.0 No repository field.
4:44:42 PM: added 235 packages from 163 contributors and audited 654 packages in 5.179s
4:44:42 PM: 4 packages are looking for funding
4:44:42 PM: run npm fund for details
4:44:42 PM: found 1 high severity vulnerability
4:44:42 PM: run npm audit fix to fix them, or npm audit for details
4:44:42 PM: NPM modules installed
4:44:43 PM: Started restoring cached go cache
4:44:43 PM: Finished restoring cached go cache
4:44:43 PM: go version go1.12 linux/amd64
4:44:43 PM: go version go1.12 linux/amd64
4:44:43 PM: Installing missing commands
4:44:43 PM: Verify run directory
4:44:43 PM: Executing user command: npm run build
4:44:43 PM: npm
4:44:43 PM: ERR! missing script: build
4:44:43 PM: npm
4:44:43 PM: ERR! A complete log of this run can be found in:
4:44:43 PM: npm ERR!
4:44:43 PM: /opt/buildhome/.npm/_logs/2020-05-12T15_44_43_661Z-debug.log
4:44:43 PM: Skipping functions preparation step: no functions directory set
4:44:43 PM: Caching artifacts
4:44:43 PM: Started saving node modules
4:44:43 PM: Finished saving node modules
4:44:43 PM: Started saving pip cache
4:44:43 PM: Finished saving pip cache
4:44:43 PM: Started saving emacs cask dependencies
4:44:43 PM: Finished saving emacs cask dependencies
4:44:43 PM: Started saving maven dependencies
4:44:43 PM: Finished saving maven dependencies
4:44:43 PM: Started saving boot dependencies
4:44:43 PM: Finished saving boot dependencies
4:44:43 PM: Started saving go dependencies
4:44:43 PM: Finished saving go dependencies
4:44:47 PM: Error running command: Build script returned non-zero exit code: 1
4:44:47 PM: Failing build: Failed to build site
4:44:47 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1
4:44:47 PM: Finished processing build request in 16.41890585s

can anyone help me with this issue? Thank you

Hey there,
It looks like, even though you set npm run build as the build command in the Netlify UI, you don’t have “build” in your package.json. That’s what this error message says to me:

4:44:43 PM: Executing user command: npm run build
4:44:43 PM: npm
4:44:43 PM: ERR! missing script: build

You’ll either need that in your package.json (in addition to in the UI), or you can change your build command in the Netlify UI to just be the build command for whatever static site generator (SSG) you’re using. I can’t tell which SSG that is based on your logs, but if you’d like to share your Netlify URL, we can probably help you find it!

Sharing our docs on common build command configurations here as well just in case it’s helpful :slight_smile:

Inside the build command, what exactly am I meant to write in order for it to run? I would send the url but I deleted the website after messing around with it for a few hours.

1 Like

It depends on what you’re building. For example, if you click the “Deploy to Netlify” button under Gatsby here:

It deploys this repo:

And the build command is in the package.json here:

But that would look different for a different static site generator. Hope this helps! If you want to give it another shot, we’d be happy to help you troubleshoot in the future.

In the image above, you’re able to see my package.json file. What am i missing in order for it to deploy correctly? Also, do i need a SSG in order to deploy it?

I am new to deploying sites via this method, i usually have a github repo where my index.html is in the root directory so netlify can target it without any build commands, so what i may be saying might not make sense when it comes to trying to deploy it via a build command.

Ahh, I see. In this case, you have an index.html in the publish folder (you mentioned you set it to “dist/” which looks correct to me based on the screenshot you shared) and there’s actually no building happening here. So I believe you would actually delete the build command from the Netlify UI. That way, Netlify will find your index.html and publish it.

if i dont include a build command when deploying the site, it cant seem to find the index.html file, probably because its not in the root folder, its in the dist folder. I, then set the publish directory in netlify to dist and the still wont deploy the website. Itll deploy it but when i click on the link, it says cannot find site. I can deploy the website if i just create a new repo in github with the files in the dist folder but then the .scss files wont be in there, im not too sure if i need to include the package.json or or the scss folder.

Okay, now for some reason after deleting the entire website that i tried to deploy first, it now works when resetting it all and deploying another brand new site. Abit weird but hey, it works lol. Thank you for your help Jen!

:partying_face::partying_face: