Home
Support Forums

Npm ERR! path /opt/build/repo/package.json

Here is the link to my repo https://github.com/kenscore/KKOCV1

Every time I try to build my site I receive this error and I’m unsure on what the issue is

8:27:04 PM: Build ready to start
8:27:06 PM: build-image version: 73def8bb10593b9b818f44989a75ea508018ccb7 (focal)
8:27:06 PM: build-image tag: v4.5.2
8:27:06 PM: buildbot version: e07f38cea73012d29c839c78dec87335277fe704
8:27:06 PM: Building without cache
8:27:06 PM: Starting to prepare the repo for build
8:27:07 PM: No cached dependencies found. Cloning fresh repo
8:27:07 PM: git clone https://github.com/kenscore/KKOCV1
8:27:09 PM: Preparing Git Reference refs/heads/main
8:27:10 PM: Parsing package.json dependencies
8:27:10 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: β€˜β€™ versus β€˜/’ in the Netlify UI
8:27:10 PM: Starting build script
8:27:10 PM: Installing dependencies
8:27:10 PM: Python version set to 2.7
8:27:11 PM: v16.13.1 is already installed.
8:27:11 PM: Now using node v16.13.1 (npm v8.1.2)
8:27:12 PM: Started restoring cached build plugins
8:27:12 PM: Finished restoring cached build plugins
8:27:12 PM: Attempting ruby version 2.7.2, read from environment
8:27:13 PM: Using ruby version 2.7.2
8:27:13 PM: Using PHP version 8.0
8:27:13 PM: Started restoring cached go cache
8:27:13 PM: Finished restoring cached go cache
8:27:13 PM: go version go1.16.5 linux/amd64
8:27:13 PM: go version go1.16.5 linux/amd64
8:27:13 PM: Installing missing commands
8:27:13 PM: Verify run directory
8:27:15 PM: ​
8:27:15 PM: ────────────────────────────────────────────────────────────────
8:27:15 PM: Netlify Build
8:27:15 PM: ────────────────────────────────────────────────────────────────
8:27:15 PM: ​
8:27:15 PM: ❯ Version
8:27:15 PM: @netlify/build 26.0.2
8:27:15 PM: ​
8:27:15 PM: ❯ Flags
8:27:15 PM: baseRelDir: true
8:27:15 PM: buildId: 61d26d088b3f27fc440aabf8
8:27:15 PM: deployId: 61d26d088b3f27fc440aabfa
8:27:15 PM: ​
8:27:15 PM: ❯ Current directory
8:27:15 PM: /opt/build/repo
8:27:15 PM: ​
8:27:15 PM: ❯ Config file
8:27:15 PM: No config file was defined: using default values.
8:27:15 PM: ​
8:27:15 PM: ❯ Context
8:27:15 PM: production
8:27:15 PM: ​
8:27:15 PM: ────────────────────────────────────────────────────────────────
8:27:15 PM: 1. Build command from Netlify app
8:27:15 PM: ────────────────────────────────────────────────────────────────
8:27:15 PM: ​
8:27:15 PM: $ CI= npm run build
8:27:15 PM: npm ERR! code ENOENT
8:27:15 PM: npm ERR! syscall open
8:27:15 PM: npm ERR! path /opt/build/repo/package.json
8:27:15 PM: npm ERR! errno -2
8:27:15 PM: npm ERR! enoent ENOENT: no such file or directory, open β€˜/opt/build/repo/package.json’
8:27:15 PM: npm ERR! enoent This is related to npm not being able to find a file.
8:27:15 PM: npm ERR! enoent
8:27:15 PM: npm ERR! A complete log of this run can be found in:
8:27:15 PM: npm ERR! /opt/buildhome/.npm/_logs/2022-01-03T03_27_15_920Z-debug.log
8:27:15 PM: ​
8:27:15 PM: ────────────────────────────────────────────────────────────────
8:27:15 PM: β€œbuild.command” failed
8:27:15 PM: ────────────────────────────────────────────────────────────────
8:27:15 PM: ​
8:27:15 PM: Error message
8:27:15 PM: Command failed with exit code 254: CI= npm run build
8:27:15 PM: ​
8:27:15 PM: Error location
8:27:15 PM: In Build command from Netlify app:
8:27:15 PM: CI= npm run build
8:27:15 PM: ​
8:27:15 PM: Resolved config
8:27:15 PM: build:
8:27:15 PM: base: /opt/build/repo
8:27:15 PM: command: CI= npm run build
8:27:15 PM: commandOrigin: ui
8:27:15 PM: publish: /opt/build/repo/build
8:27:15 PM: publishOrigin: ui
8:27:16 PM: Caching artifacts
8:27:16 PM: Started saving build plugins
8:27:16 PM: Finished saving build plugins
8:27:16 PM: Started saving pip cache
8:27:16 PM: Finished saving pip cache
8:27:16 PM: Started saving emacs cask dependencies
8:27:16 PM: Finished saving emacs cask dependencies
8:27:16 PM: Started saving maven dependencies
8:27:16 PM: Finished saving maven dependencies
8:27:16 PM: Started saving boot dependencies
8:27:16 PM: Finished saving boot dependencies
8:27:16 PM: Started saving rust rustup cache
8:27:16 PM: Finished saving rust rustup cache
8:27:16 PM: Started saving go dependencies
8:27:16 PM: Finished saving go dependencies
8:27:18 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:27:18 PM: Creating deploy upload records
8:27:18 PM: Failing build: Failed to build site
8:27:18 PM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
8:27:18 PM: Finished processing build request in 11.94926067s

Hi @kenscore

Welcome to the forums.

In this case the Build from a subdirectory or monorepo documentation applies. There is no package.json in the root of the repository, it is in the directory nft-minting-app-main 2.

First I suggest changing the name from nft-minting-app-main 2 to nft-minting-app-main-2 removing the space.
Second, as per the above documentation, set the base directory to nft-minting-app-main-2 and the publish directory to nft-minting-app-main-2/build (build is standing React output directory.)

If you have any further questions/issues, do not hesitate to reply.

Every time I run my build it comes up with this error

My repo link is GitHub - kenscore/KKOC17

8:23:47 PM: ​
8:23:47 PM: $ npm run bulid
8:23:48 PM: npm ERR! Missing script: β€œbulid”
8:23:48 PM: npm ERR!
8:23:48 PM: npm ERR! To see a list of scripts, run:
8:23:48 PM: npm ERR! npm run
8:23:48 PM: npm ERR! A complete log of this run can be found in:
8:23:48 PM: npm ERR! /opt/buildhome/.npm/_logs/2022-01-04T03_23_48_028Z-debug.log
8:23:48 PM: ​
8:23:48 PM: ────────────────────────────────────────────────────────────────
8:23:48 PM: β€œbuild.command” failed
8:23:48 PM: ────────────────────────────────────────────────────────────────

Have you followed the information I previously mentioned @kenscore ?

Can you provide a screenshot of your build settings.

Yes, I did. The repo above is new, it worked when I did the things above as you stated but I accidentally deleted the repo on github so the one above is the same as the old one but a different repo however, it isn’t working and now instead is stating that it is missing the script β€˜build’

Screen Shot 2022-01-03 at 9.08.27 PM

You have misspelled build

1 Like

Thank you for catching that!

1 Like