【问题标题】:Netlify build failed with non-zero exit code: 1Netlify 构建失败,退出代码非零:1
【发布时间】:2020-09-10 18:23:06
【问题描述】:

我正在尝试通过 GitHub 在 Netlify 上托管我的网站,但是我收到了一个错误。它是用 vanilla JS、HTML 和 CSS 构建的。我收到了exit code: 254,但后来我创建了一个 package.json 文件,现在我收到了exit code: 1。当我在开发模式下运行我的网站时,我没有任何问题。我查看了各种问题和答案,但尚未找到解决方案。

我该如何解决这个问题?

部署日志

9:02:16 PM: Build ready to start
9:02:19 PM: build-image version: 6b66e79d54a8f76b01392124644c3052ac0d32ef
9:02:19 PM: build-image tag: v3.3.6
9:02:19 PM: buildbot version: 2ba6f2db8150441c8469e6ae3ab3561a2c9d03fa
9:02:19 PM: Fetching cached dependencies
9:02:19 PM: Starting to download cache of 254.9KB
9:02:19 PM: Finished downloading cache in 67.429279ms
9:02:19 PM: Starting to extract cache
9:02:19 PM: Failed to fetch cache, continuing with build
9:02:19 PM: Starting to prepare the repo for build
9:02:19 PM: No cached dependencies found. Cloning fresh repo
9:02:19 PM: git clone https://github.com/Rahni1/App-Dev-Portfolio
9:02:21 PM: Preparing Git Reference refs/heads/master
9:02:22 PM: Starting build script
9:02:22 PM: Installing dependencies
9:02:23 PM: v10.19.0 is already installed.
9:02:24 PM: Now using node v10.19.0 (npm v6.13.4)
9:02:24 PM: Attempting ruby version 2.6.2, read from environment
9:02:25 PM: Using ruby version 2.6.2
9:02:25 PM: Using PHP version 5.6
9:02:25 PM: Started restoring cached node modules
9:02:25 PM: Finished restoring cached node modules
9:02:26 PM: Installing NPM modules using NPM version 6.13.4
9:02:26 PM: npm
9:02:26 PM:  notice created a lockfile as package-lock.json. You should commit this file.
9:02:26 PM: npm WARN
9:02:26 PM:  portfolio@1.0.0 No description
9:02:27 PM: up to date in 0.347s
9:02:27 PM: found 0 vulnerabilities
9:02:27 PM: NPM modules installed
9:02:27 PM: Started restoring cached go cache
9:02:27 PM: Finished restoring cached go cache
9:02:27 PM: unset GOOS;
9:02:27 PM: unset GOARCH;
9:02:27 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
9:02:27 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
9:02:27 PM: go version >&2;
9:02:27 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
9:02:27 PM: go version go1.12 linux/amd64
9:02:27 PM: Installing missing commands
9:02:27 PM: Verify run directory
9:02:27 PM: Executing user command: npm run build
9:02:27 PM: npm
9:02:27 PM: ERR!
9:02:27 PM:  missing script: build
9:02:27 PM: npm
9:02:27 PM: ERR! A complete log of this run can be found in:
9:02:27 PM: npm ERR!     /opt/buildhome/.npm/_logs/2020-03-10T20_02_27_867Z-debug.log
9:02:27 PM: Skipping functions preparation step: no functions directory set
9:02:27 PM: Caching artifacts
9:02:27 PM: Started saving node modules
9:02:27 PM: Finished saving node modules
9:02:27 PM: Started saving pip cache
9:02:27 PM: Finished saving pip cache
9:02:27 PM: Started saving emacs cask dependencies
9:02:27 PM: Finished saving emacs cask dependencies
9:02:27 PM: Started saving maven dependencies
9:02:27 PM: Finished saving maven dependencies
9:02:27 PM: Started saving boot dependencies
9:02:28 PM: Finished saving boot dependencies
9:02:28 PM: Started saving go dependencies
9:02:28 PM: Finished saving go dependencies
9:02:30 PM: Error running command: Build script returned non-zero exit code: 1
9:02:30 PM: Failing build: Failed to build site
9:02:30 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
9:02:30 PM: Finished processing build request in 11.684569294s

包.json

{
  "name": "portfolio",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Rahni1/App-Dev-Portfolio.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://link-to-github-repo/issues"
  },
  "homepage": "https://link-to-github-repo#readme"
}

【问题讨论】:

    标签: build netlify


    【解决方案1】:

    Netlify 尝试运行 npm run build。您的 package.json 中不包含这样的脚本,您需要添加一个并重试。

    【讨论】:

      【解决方案2】:

      我不确定它是否会对您有所帮助,但请尝试将您的构建命令更改为 CI= npm run build

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-06-19
        • 2022-06-13
        • 2019-10-26
        • 2019-02-24
        • 1970-01-01
        • 2021-02-04
        • 1970-01-01
        • 2020-12-28
        相关资源
        最近更新 更多