首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >部署失败的Netlify

部署失败的Netlify
EN

Stack Overflow用户
提问于 2020-09-04 12:00:27
回答 3查看 8.3K关注 0票数 2

我得到了以下错误

代码语言:javascript
复制
npm ERR! enoent ENOENT: no such file or directory, open '/opt/build/repo/package.json'

以下是完整的构建日志:

代码语言:javascript
复制
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
EN

回答 3

Stack Overflow用户

发布于 2021-06-06 17:55:15

在使用netlify构建站点时,使用命令"CI= npm运行构建“而不是默认的"npm运行生成”。

票数 9
EN

Stack Overflow用户

发布于 2020-10-07 00:13:14

解决方法是从您的/build中删除.gitignore,然后从netlify中的构建设置中删除build命令( settings或npm )。

票数 2
EN

Stack Overflow用户

发布于 2021-11-16 16:44:22

在我的例子中,切换到Ubuntu 16.04是有帮助的。

  1. 转到:站点设置>生成&部署>生成映像选择>编辑设置。
  2. 选择Ubuntu 16.05
  3. 保存并重新运行部署。

注意:

  • 如果您构建/部署了一个旧站点,并且需要使用该依赖项的旧版本(Node、npm、Yarn、PHP等),请在“环境变量”部分设置版本。在Netlify文档中阅读更多关于构建环境变量的信息。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63740794

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档