Eithar Alatoom
Eithar Alatoom

Reputation: 61

Deploy failed Netlify

I'm getting the following error

npm ERR! enoent ENOENT: no such file or directory, open '/opt/build/repo/package.json'

Here's the full build log:

2:27:28 PM: Waiting for other deploys from your team to complete
2:27:30 PM: Build ready to start
2:27:32 PM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
2:27:32 PM: build-image tag: v3.4.1
2:27:32 PM: buildbot version: e1f4178b0d9779ebad1b11d5b54739f82fed3c22
2:27:32 PM: Building without cache
2:27:32 PM: Starting to prepare the repo for build
2:27:32 PM: No cached dependencies found. Cloning fresh repo
2:27:32 PM: git clone https://github.com/EitharAlotoom95/Eithar-Website-
2:27:33 PM: Preparing Git Reference refs/heads/master
2:27:34 PM: Starting build script
2:27:35 PM: Installing dependencies
2:27:35 PM: Python version set to 2.7
2:27:36 PM: v12.18.0 is already installed.
2:27:36 PM: Now using node v12.18.0 (npm v6.14.4)
2:27:36 PM: Started restoring cached build plugins
2:27:36 PM: Finished restoring cached build plugins
2:27:36 PM: Attempting ruby version 2.7.1, read from environment
2:27:38 PM: Using ruby version 2.7.1
2:27:38 PM: Using PHP version 5.6
2:27:38 PM: 5.2 is already installed.
2:27:38 PM: Using Swift version 5.2
2:27:38 PM: Started restoring cached go cache
2:27:38 PM: Finished restoring cached go cache
2:27:38 PM: go version go1.14.4 linux/amd64
2:27:38 PM: go version go1.14.4 linux/amd64
2:27:38 PM: Installing missing commands
2:27:38 PM: Verify run directory
2:27:39 PM: ​
2:27:39 PM: ┌─────────────────────────────┐
2:27:39 PM: │        Netlify Build        │
2:27:39 PM: └─────────────────────────────┘
2:27:39 PM: ​
2:27:39 PM: ❯ Version
2:27:39 PM:   @netlify/build 3.3.5
2:27:39 PM: ​
2:27:39 PM: ❯ Flags
2:27:39 PM:   deployId: 5f5224a05574348ce34178f9
2:27:39 PM:   mode: buildbot
2:27:39 PM: ​
2:27:39 PM: ❯ Current directory
2:27:39 PM:   /opt/build/repo
2:27:39 PM: ​
2:27:39 PM: ❯ Config file
2:27:39 PM:   No config file was defined: using default values.
2:27:39 PM: ​
2:27:39 PM: ❯ Context
2:27:39 PM:   production
2:27:39 PM: ​
2:27:39 PM: ┌───────────────────────────────────┐
2:27:39 PM: │ 1. Build command from Netlify app │
2:27:39 PM: └───────────────────────────────────┘
2:27:39 PM: ​
2:27:39 PM: $ npm run build
2:27:39 PM: npm ERR! code ENOENT
2:27:39 PM: npm ERR! syscall open
2:27:39 PM: npm ERR! path /opt/build/repo/package.json
2:27:39 PM: npm ERR! errno -2
2:27:39 PM: npm ERR! enoent ENOENT: no such file or directory, open '/opt/build/repo/package.json'
2:27:39 PM: npm ERR! enoent This is related to npm not being able to find a file.
2:27:39 PM: npm ERR! enoent
2:27:39 PM: npm ERR! A complete log of this run can be found in:
2:27:39 PM: npm ERR!     /opt/buildhome/.npm/_logs/2020-09-04T11_27_39_874Z-debug.log
2:27:39 PM: ​
2:27:39 PM: ┌─────────────────────────────┐
2:27:39 PM: │   "build.command" failed    │
2:27:39 PM: └─────────────────────────────┘
2:27:39 PM: ​
2:27:39 PM:   Error message
2:27:39 PM:   Command failed with exit code 254: npm run build
2:27:39 PM: ​
2:27:39 PM:   Error location
2:27:39 PM:   In Build command from Netlify app:
2:27:39 PM:   npm run build
2:27:39 PM: ​
2:27:39 PM:   Resolved config
2:27:39 PM:   build:
2:27:39 PM:     command: npm run build
2:27:39 PM:     commandOrigin: ui
2:27:39 PM:     publish: /opt/build/repo/dist
2:27:40 PM: Caching artifacts
2:27:40 PM: Started saving build plugins
2:27:40 PM: Finished saving build plugins
2:27:40 PM: Started saving pip cache
2:27:40 PM: Finished saving pip cache
2:27:40 PM: Started saving emacs cask dependencies
2:27:40 PM: Finished saving emacs cask dependencies
2:27:40 PM: Started saving maven dependencies
2:27:40 PM: Finished saving maven dependencies
2:27:40 PM: Started saving boot dependencies
2:27:40 PM: Finished saving boot dependencies
2:27:40 PM: Started saving go dependencies
2:27:40 PM: Finished saving go dependencies
2:27:42 PM: Error running command: Build script returned non-zero exit code: 1
2:27:42 PM: Failing build: Failed to build site
2:27:42 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
2:27:42 PM: Finished processing build request in 10.743452323s

Upvotes: 6

Views: 16176

Answers (6)

Nofil Bashir
Nofil Bashir

Reputation: 1

use build command CI=false npm run build Netlify somehow treats warnings as errors, CI=false says , just deploy ,dont worry about warnings CI=false npm run build

Upvotes: 0

Maureen Josephine
Maureen Josephine

Reputation: 516

Experienced a similar issue with Deploying on Netlify after switching from Gatsby to Hugo

This worked for me:

On your Netlify Deploy Settings, under build, place this Build Settings: hugo --gc

enter image description here

Then Clear the cache and re-run the Deploy to trigger the build once more.

Upvotes: 0

Amit Baderia
Amit Baderia

Reputation: 4892

My deployment was also failing, the command I was using

CI=npm run build

I didn`t notice before, but when I added extra space after "CI=" and modified the command as shown below, it worked for me

CI= npm run build

Netify use "CI" environment variable for Continuous Integration

Upvotes: 1

Dariusz Woźniak
Dariusz Woźniak

Reputation: 10350

In my case, switching to Ubuntu Xenial 16.04 helped.

  1. Go to: Site settings > Build & deploy > Build image selection > Edit settings.
  2. Choose Ubuntu Xenial 16.05.
  3. Save and rerun deployment.

Build image selection

Note:

  • If you build/deploy an older site, and you need to use an older version of the dependency (Node, npm, Yarn, PHP, etc.), set version in the Environment variables section. Read more on Build environment variables at Netlify documentation.

Upvotes: 1

Madesha A
Madesha A

Reputation: 141

While building the site using netlify, use command "CI= npm run build" instead of default "npm run build"

Upvotes: 14

Yos
Yos

Reputation: 83

A workaround is removing /build from your .gitignore and then removing the build command (yarn build or npm run build) from the build settings in netlify.

Upvotes: 2

Related Questions