【问题标题】:Netlify Deploy Command failed with exit code 254: npm run build-studio && cp studio/netlify.toml studio/distNetlify 部署命令失败,退出代码 254:npm run build-studio && cp studio/netlify.toml studio/dist
【发布时间】:2021-11-07 21:47:36
【问题描述】:

请帮忙!我是新手!尝试使用 Sanity 的 Gatsby 投资组合模板在 Netlify 上部署我的第一个站点。它第一次部署得很好,然后我做了一些编辑,现在它失败了,“命令失败,退出代码 254:npm run build-studio && cp studio/netlify.toml studio/dist”。该站点始终在本地构建和运行,没有任何问题。

我已经尝试了很多东西,比如删除根目录以及 studio 和 web 文件夹中的 package-lock.json 和/或 node_modules 文件夹,然后再次运行“npm install”。在 root 和 studio 和 web 文件夹中尝试了“npm update”。尝试修改根文件夹的 package.json 文件中的 postinstall 脚本。尝试运行“npm install --force --legacy-peer-deps”。尝试清理根目录、工作室和网络文件夹中的缓存。基本上尝试了我在 Netlify 论坛和 Stackoverflow 论坛以及其他地方搜索我的问题时看到的所有内容……

这里是 github 仓库:https://github.com/ericerodgers/portfolio

这里是部署似乎中断的地方:

    11:01:47 PM: lerna info Installing external dependencies
    11:04:48 PM: lerna ERR! npm ci exited 254 in ‘sanity-gatsby-portfolio-studio’
    11:04:48 PM: lerna ERR! npm ci stderr:
    11:04:48 PM: npm WARN tarball tarball data for which- 
   module@https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz (sha1- 
   2e8H3Od7mQK4o6j6SzHD4/fm6Ho=) seems to be corrupted. Trying again.

这是“npm WARN tarball tarball data…”一行一行之后的错误信息:

    11:04:48 PM: “build.command” failed
    11:04:48 PM: ────────────────────────────────────────────────────────────────
    11:04:48 PM: ​
    11:04:48 PM: Error message
    11:04:48 PM: Command failed with exit code 254: npm run build-studio && cp 
    studio/netlify.toml studio/dist
    11:04:48 PM: ​
    11:04:48 PM: Error location
    11:04:48 PM: In Build command from Netlify app:
    11:04:48 PM: npm run build-studio && cp studio/netlify.toml studio/dist
    11:04:48 PM: ​
    11:04:48 PM: Resolved config
    11:04:48 PM: build:
    11:04:48 PM: base: /opt/build/repo
    11:04:48 PM: command: npm run build-studio && cp studio/netlify.toml studio/dist
    11:04:48 PM: commandOrigin: ui
    11:04:48 PM: environment:
    11:04:48 PM: - NETLIFY_BUILD_DEBUG
    11:04:48 PM: publish: /opt/build/repo/studio/dist
    11:04:48 PM: publishOrigin: ui

这是完整的部署日志(减去一大块“npm WARN tarball tarball data...”行):

11:01:25 PM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0
11:01:25 PM: build-image tag: v4.3.0
11:01:25 PM: buildbot version: bfa1ece451875e5fe124c5b0a59bb85e0abb8d50
11:01:25 PM: Fetching cached dependencies
11:01:25 PM: Starting to download cache of 147.2MB
11:01:27 PM: Finished downloading cache in 1.527898759s
11:01:27 PM: Starting to extract cache
11:01:32 PM: Finished extracting cache in 5.608708305s
11:01:32 PM: Finished fetching cache in 7.332795262s
11:01:32 PM: Starting to prepare the repo for build
11:01:33 PM: Preparing Git Reference refs/heads/main
11:01:34 PM: Parsing package.json dependencies
11:01:34 PM: 
​
❯ Initial build environment
baseRelDir: true
branch: main
context: production
cwd: /opt/build/repo
featureFlags: []
mode: buildbot
repositoryRoot: /opt/build/repo
siteId: 0e615e6e-e933-48da-a5c5-0e7c3826be41
​
❯ UI build settings
baseRelDir: true
build:
  base: /
  command: npm run build-studio && cp studio/netlify.toml studio/dist
  environment:
    - NETLIFY_BUILD_DEBUG
  publish: /studio/dist
​
❯ Resolved build environment
branch: main
buildDir: /opt/build/repo
context: production
env: []
​
❯ Resolved config
build:
  base: /opt/build/repo
  command: npm run build-studio && cp studio/netlify.toml studio/dist
  commandOrigin: ui
  environment:
    - NETLIFY_BUILD_DEBUG
  publish: /opt/build/repo/studio/dist
  publishOrigin: ui

11:01:34 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: '' versus '/' in the Netlify UI
11:01:34 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'studio/dist' versus '/studio/dist' in the Netlify UI
11:01:35 PM: Starting build script
11:01:35 PM: Installing dependencies
11:01:35 PM: Python version set to 2.7
11:01:35 PM: Started restoring cached node version
11:01:39 PM: Finished restoring cached node version
11:01:40 PM: v16.9.1 is already installed.
11:01:40 PM: Now using node v16.9.1 (npm v7.21.1)
11:01:41 PM: Started restoring cached build plugins
11:01:41 PM: Finished restoring cached build plugins
11:01:41 PM: Attempting ruby version 2.7.2, read from environment
11:01:43 PM: Using ruby version 2.7.2
11:01:43 PM: Using PHP version 8.0
11:01:43 PM: Started restoring cached node modules
11:01:43 PM: Finished restoring cached node modules
11:01:43 PM: Started restoring cached go cache
11:01:43 PM: Finished restoring cached go cache
11:01:44 PM: go version go1.16.5 linux/amd64
11:01:44 PM: go version go1.16.5 linux/amd64
11:01:44 PM: Installing missing commands
11:01:44 PM: Verify run directory
11:01:45 PM: ​
11:01:45 PM: ────────────────────────────────────────────────────────────────
11:01:45 PM:   Netlify Build                                                 
11:01:45 PM: ────────────────────────────────────────────────────────────────
11:01:45 PM: ​
11:01:45 PM: ❯ Version
11:01:45 PM:   @netlify/build 18.8.0
11:01:45 PM: ​
11:01:45 PM: ❯ Flags
11:01:45 PM:   apiHost: api.netlify.com
11:01:45 PM:   baseRelDir: true
11:01:45 PM:   branch: main
11:01:45 PM:   buildId: 613d6d7bf1748000085c421b
11:01:45 PM:   buildbotServerSocket: /tmp/netlify-buildbot-socket
11:01:45 PM:   cacheDir: /opt/build/cache
11:01:45 PM:   cachedConfigPath: /tmp/netlify_config.json
11:01:45 PM:   context: production
11:01:45 PM:   cwd: /opt/build/repo
11:01:45 PM:   deployId: 613d6d7bf1748000085c421d
11:01:45 PM:   featureFlags:
11:01:45 PM:     - zisiEsbuildDynamicImports
11:01:45 PM:   framework: unknown
11:01:45 PM:   functionsDistDir: /tmp/zisi-613d6d7bf1748000085c421d
11:01:45 PM:   mode: buildbot
11:01:45 PM:   nodePath: /opt/buildhome/.nvm/versions/node/v16.9.1/bin/node
11:01:45 PM:   repositoryRoot: /opt/build/repo
11:01:45 PM:   saveConfig: true
11:01:45 PM:   sendStatus: true
11:01:45 PM:   siteId: 0e615e6e-e933-48da-a5c5-0e7c3826be41
11:01:45 PM:   statsd:
11:01:45 PM:     host: datadog-agent
11:01:45 PM:     port: 8125
11:01:45 PM:   testOpts:
11:01:45 PM:     silentLingeringProcesses: ''
11:01:45 PM: ​
11:01:45 PM: ❯ Current directory
11:01:45 PM:   /opt/build/repo
11:01:45 PM: ​
11:01:45 PM: ❯ Config file
11:01:45 PM:   No config file was defined: using default values.
11:01:45 PM: ​
11:01:45 PM: ❯ Resolved config
11:01:45 PM:   build:
11:01:45 PM:     base: /opt/build/repo
11:01:45 PM:     command: npm run build-studio && cp studio/netlify.toml studio/dist
11:01:45 PM:     commandOrigin: ui
11:01:45 PM:     environment:
11:01:45 PM:       - NETLIFY_BUILD_DEBUG
11:01:45 PM:     publish: /opt/build/repo/studio/dist
11:01:45 PM:     publishOrigin: ui
11:01:45 PM: ​
11:01:45 PM: ❯ Context
11:01:45 PM:   production
11:01:45 PM: ​
11:01:45 PM: ────────────────────────────────────────────────────────────────
11:01:45 PM:   1. Build command from Netlify app                             
11:01:45 PM: ────────────────────────────────────────────────────────────────
11:01:45 PM: ​
11:01:45 PM: $ npm run build-studio && cp studio/netlify.toml studio/dist
11:01:46 PM: > sanity-gatsby-portfolio@0.0.0 build-studio
11:01:46 PM: > lerna bootstrap && (cd studio && npm run build)
11:01:46 PM: lerna notice cli v4.0.0
11:01:46 PM: lerna info ci enabled
11:01:47 PM: lerna info Bootstrapping 2 packages
11:01:47 PM: lerna info Installing external dependencies
11:04:48 PM: lerna ERR! npm ci exited 254 in 'sanity-gatsby-portfolio-studio'
11:04:48 PM: lerna ERR! npm ci stderr:
11:04:48 PM: npm WARN tarball tarball data for which-module@https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz (sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=) seems to be corrupted. Trying again.
11:04:48 PM: npm WARN tarball tarball data for normalize-path@https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz (sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=) seems to be corrupted. Trying again.
11:04:48 PM: npm ERR! code ENOENT
11:04:48 PM: npm ERR! syscall lstat
11:04:48 PM: npm ERR! path /opt/buildhome/.npm/_cacache/content-v2/sha1/b5/24/3d8f3ec1aa35f1364605bc0d1036e30ab69f
11:04:48 PM: npm ERR! errno -2
11:04:48 PM: npm ERR! enoent ENOENT: no such file or directory, lstat '/opt/buildhome/.npm/_cacache/content-v2/sha1/b5/24/3d8f3ec1aa35f1364605bc0d1036e30ab69f'
11:04:48 PM: npm ERR! enoent This is related to npm not being able to find a file.
11:04:48 PM: npm ERR! enoent
11:04:48 PM: npm ERR! A complete log of this run can be found in:
11:04:48 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-09-12T03_04_47_826Z-debug.log
11:04:48 PM: lerna ERR! npm ci exited 254 in 'sanity-gatsby-portfolio-studio'
11:04:48 PM: ​
11:04:48 PM: ────────────────────────────────────────────────────────────────
11:04:48 PM:   "build.command" failed                                        
11:04:48 PM: ────────────────────────────────────────────────────────────────
11:04:48 PM: ​
11:04:48 PM:   Error message
11:04:48 PM:   Command failed with exit code 254: npm run build-studio && cp studio/netlify.toml studio/dist
11:04:48 PM: ​
11:04:48 PM:   Error location
11:04:48 PM:   In Build command from Netlify app:
11:04:48 PM:   npm run build-studio && cp studio/netlify.toml studio/dist
11:04:48 PM: ​
11:04:48 PM:   Resolved config
11:04:48 PM:   build:
11:04:48 PM:     base: /opt/build/repo
11:04:48 PM:     command: npm run build-studio && cp studio/netlify.toml studio/dist
11:04:48 PM:     commandOrigin: ui
11:04:48 PM:     environment:
11:04:48 PM:       - NETLIFY_BUILD_DEBUG
11:04:48 PM:     publish: /opt/build/repo/studio/dist
11:04:48 PM:     publishOrigin: ui
11:04:48 PM: Caching artifacts
11:04:48 PM: Started saving node modules
11:04:48 PM: Finished saving node modules
11:04:48 PM: Started saving build plugins
11:04:48 PM: Finished saving build plugins
11:04:48 PM: Started saving pip cache
11:04:48 PM: Finished saving pip cache
11:04:48 PM: Started saving emacs cask dependencies
11:04:48 PM: Finished saving emacs cask dependencies
11:04:48 PM: Started saving maven dependencies
11:04:48 PM: Finished saving maven dependencies
11:04:48 PM: Started saving boot dependencies
11:04:48 PM: Finished saving boot dependencies
11:04:48 PM: Started saving rust rustup cache
11:04:48 PM: Finished saving rust rustup cache
11:04:48 PM: Started saving go dependencies
11:04:48 PM: Finished saving go dependencies
11:04:48 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:04:48 PM: Failing build: Failed to build site
11:04:48 PM: Finished processing build request in 3m23.585558362s```

【问题讨论】:

    标签: deployment netlify lerna sanity


    【解决方案1】:

    在 netlify 论坛中 @coelmay 的帮助下,我得到了这个问题的回答... https://answers.netlify.com/t/netlify-deploy-command-failed-with-exit-code-254-npm-run-build-studio-cp-studio-netlify-toml-studio-dist/44017/2

    我删除了 yarn.lock 文件,从工作室构建脚本中删除了“&& lerna bootstrap”,并编辑了 netlify.toml 文件以读取: [建造] command = "CI= npm run build"

    我通过这些更改从根投资组合文件夹部署到 netlify,并且 sanity studio 构建完成,但 gatsby 网站失败,出现一些错误代码,表明 sanity 架构存在问题……在 Sanity.io UI 中,我看到一条错误消息询问如果我想删除一个我认为我已经成功删除的架构,我确认了删除。我在本地重新部署了 graphql,最后一次重新部署了站点,现在一切正常!

    我真的不知道我是如何或为什么有一个 yarn.lock 文件,也不知道为什么工作室构建脚本包含“lerna bootstrap”,我并没有对我找到的 sanity/gatsby 投资组合模板进行非常大的改动sanity.io……我主要只是添加了新内容。

    非常感谢 netlify 论坛中的 @coelmay 帮助我解决这个问题。祝其他在调整和部署此 sanity/gatsby 投资组合模板时遇到类似问题的人好运!

    【讨论】:

      猜你喜欢
      • 2021-07-27
      • 2020-04-23
      • 2018-09-14
      • 2021-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-08
      • 2020-11-27
      相关资源
      最近更新 更多