I got error code 254 and I don't know how to fix it

I’m new to coding, I’m trying to build a website using html and css, but netlify isn’t deploying it, I need a step by step explanation because I’m really bad at understanding certain things, thanks.

Netlify site name and logs:
jolly-hopper-4fc489

5:21:01 PM: Build ready to start
5:21:03 PM: build-image version: 122b31996ccaffd45d820a452d6227f8312110cc (focal)
5:21:03 PM: build-image tag: v4.5.3
5:21:03 PM: buildbot version: 94cf4881e10a7b2d529971a176d6ede22bcaeb38
5:21:03 PM: Fetching cached dependencies
5:21:04 PM: Starting to download cache of 138.5MB
5:21:04 PM: Finished downloading cache in 839.064572ms
5:21:04 PM: Starting to extract cache
5:21:09 PM: Finished extracting cache in 4.742727773s
5:21:09 PM: Finished fetching cache in 5.620395666s
5:21:09 PM: Starting to prepare the repo for build
5:21:09 PM: Preparing Git Reference refs/heads/main
5:21:14 PM: Parsing package.json dependencies
5:21:14 PM: Starting build script
5:21:15 PM: Installing dependencies
5:21:15 PM: Python version set to 2.7
5:21:15 PM: Started restoring cached node version
5:21:17 PM: Finished restoring cached node version
5:21:17 PM: v16.13.2 is already installed.
5:21:18 PM: Now using node v16.13.2 (npm v8.1.2)
5:21:18 PM: Started restoring cached build plugins
5:21:18 PM: Finished restoring cached build plugins
5:21:18 PM: Attempting ruby version 2.7.2, read from environment
5:21:20 PM: Using ruby version 2.7.2
5:21:20 PM: Using PHP version 8.0
5:21:20 PM: Started restoring cached go cache
5:21:20 PM: Finished restoring cached go cache
5:21:20 PM: go version go1.16.5 linux/amd64
5:21:20 PM: go version go1.16.5 linux/amd64
5:21:20 PM: Installing missing commands
5:21:20 PM: Verify run directory
5:21:22 PM: ​
5:21:22 PM: ────────────────────────────────────────────────────────────────
5:21:22 PM: Netlify Build
5:21:22 PM: ────────────────────────────────────────────────────────────────
5:21:22 PM: ​
5:21:22 PM: ❯ Version
5:21:22 PM: @netlify/build 26.2.2
5:21:22 PM: ​
5:21:22 PM: ❯ Flags
5:21:22 PM: baseRelDir: true
5:21:22 PM: buildId: 61f9b24d3e15b200075c852d
5:21:22 PM: deployId: 61f9b24d3e15b200075c852f
5:21:22 PM: ​
5:21:22 PM: ❯ Current directory
5:21:22 PM: /opt/build/repo
5:21:22 PM: ​
5:21:22 PM: ❯ Config file
5:21:22 PM: No config file was defined: using default values.
5:21:22 PM: ​
5:21:22 PM: ❯ Context
5:21:22 PM: production
5:21:22 PM: ​
5:21:22 PM: ────────────────────────────────────────────────────────────────
5:21:22 PM: 1. Build command from Netlify app
5:21:22 PM: ────────────────────────────────────────────────────────────────
5:21:22 PM: ​
5:21:22 PM: $ npm run build
5:21:22 PM: npm ERR! code ENOENT
5:21:22 PM: npm ERR! syscall open
5:21:22 PM: npm ERR! path /opt/build/repo/package.json
5:21:22 PM: npm ERR! errno -2
5:21:22 PM: npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/build/repo/package.json’
5:21:22 PM: npm ERR! enoent This is related to npm not being able to find a file.
5:21:22 PM: npm ERR! enoent
5:21:22 PM: npm ERR! A complete log of this run can be found in:
5:21:22 PM: npm ERR! /opt/buildhome/.npm/_logs/2022-02-01T22_21_22_971Z-debug.log
5:21:22 PM: ​
5:21:22 PM: ────────────────────────────────────────────────────────────────
5:21:22 PM: “build.command” failed
5:21:22 PM: ────────────────────────────────────────────────────────────────
5:21:22 PM: ​
5:21:22 PM: Error message
5:21:22 PM: Command failed with exit code 254: npm run build
5:21:22 PM: ​
5:21:22 PM: Error location
5:21:22 PM: In Build command from Netlify app:
5:21:22 PM: npm run build
5:21:22 PM: ​
5:21:22 PM: Resolved config
5:21:22 PM: build:
5:21:22 PM: command: npm run build
5:21:22 PM: commandOrigin: ui
5:21:22 PM: publish: /opt/build/repo/.next
5:21:22 PM: publishOrigin: ui
5:21:23 PM: Caching artifacts
5:21:23 PM: Started saving build plugins
5:21:23 PM: Finished saving build plugins
5:21:23 PM: Started saving pip cache
5:21:23 PM: Finished saving pip cache
5:21:23 PM: Started saving emacs cask dependencies
5:21:23 PM: Finished saving emacs cask dependencies
5:21:23 PM: Started saving maven dependencies
5:21:23 PM: Finished saving maven dependencies
5:21:23 PM: Started saving boot dependencies
5:21:23 PM: Finished saving boot dependencies
5:21:23 PM: Started saving rust rustup cache
5:21:23 PM: Finished saving rust rustup cache
5:21:23 PM: Started saving go dependencies
5:21:23 PM: Finished saving go dependencies
5:21:23 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:21:23 PM: Creating deploy upload records
5:21:23 PM: Failing build: Failed to build site
5:21:23 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
5:21:23 PM: Finished processing build request in 20.062720876s

Welcome to the forums @checks

The error shown above means at the root of the repository you are deploying there is no package.json file. This is crucial in Netlify Build knowing what packages are required to build the site.

If you are deploying a basic site using HTML and CSS (not using any tools such as React, Nuxt, Astro) then it is likely there is nothing that requires building. In this case, you do not need the build command npm run build—this is only required when something requires building.

Check out

If you have any issues or questions, please provide a link to the git repository you are deploying.

can you please take a look at my code, because I’m using my friends code that he gave me and his website is working, I don’t know why it would be working if I only changed/added a few things.

link: GitHub - C5J/next-netlify-starter

Your site is already built. As mentioned previously, as you are deploying a static HTML/CSS/JS site, the build command is not required. Remove the build command from the build settings and ensure the publish directory is blank also (the file exist at the root of the repository.)


On another note:
I am wondering why you used the build command npm run build? Was this something someone said you needed to do or that you read somewhere you needed to do?

1 Like