4

从昨天开始,我遇到了一个我无法修复或找到相关信息的错误。我可以在本地构建我的站点而不会出现错误,但是当我尝试在 Netlify 中部署它时它会失败并抛出:

8:19:33 AM: ​
8:19:33 AM: ┌─────────────────────────────┐
8:19:33 AM: │        Netlify Build        │
8:19:33 AM: └─────────────────────────────┘
8:19:33 AM: ​
8:19:33 AM: ❯ Version
8:19:33 AM:   @netlify/build 2.0.20
8:19:33 AM: ​
8:19:33 AM: ❯ Flags
8:19:33 AM:   deployId: 5efc2a7760231502ad0a057d
8:19:33 AM:   mode: buildbot
8:19:33 AM: ​
8:19:33 AM: ❯ Current directory
8:19:33 AM:   /opt/build/repo
8:19:33 AM: ​
8:19:33 AM: ❯ Config file
8:19:33 AM:   /opt/build/repo/netlify.toml
8:19:33 AM: ​
8:19:33 AM: ❯ Context
8:19:33 AM:   production
8:19:33 AM: ​
8:19:33 AM: ┌─────────────────────────────┐
8:19:33 AM: │     Core internal error     │
8:19:33 AM: └─────────────────────────────┘
8:19:33 AM: ​
8:19:33 AM:   Error message
8:19:33 AM:   Error: Invalid version: "1"
8:19:33 AM: ​
8:19:33 AM:   Error location
8:19:33 AM:       at Object.fixVersionField (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/normalize-package-data/lib/fixer.js:191:13)
8:19:33 AM:       at /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/normalize-package-data/lib/normalize.js:32:38
8:19:33 AM:       at Array.forEach (<anonymous>)
8:19:33 AM:       at normalize (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/normalize-package-data/lib/normalize.js:31:15)
8:19:33 AM:       at module.exports (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/read-pkg/index.js:20:36)
8:19:33 AM:       at async module.exports (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/read-pkg-up/index.js:14:16)
8:19:33 AM:       at async getPackageJson (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/utils/package.js:7:22)
8:19:33 AM:       at async build (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/main.js:61:46)
8:19:33 AM:       at async runCli (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/bin.js:17:29)
8:19:33 AM: ​
8:19:33 AM:   Error properties
8:19:33 AM:   { name: 'Error' }
8:19:33 AM: ​
8:19:33 AM: Caching artifacts
8:19:33 AM: Started saving node modules
8:19:33 AM: Finished saving node modules
8:19:33 AM: Started saving build plugins
8:19:33 AM: Finished saving build plugins
8:19:33 AM: Started saving yarn cache
8:19:33 AM: Finished saving yarn cache
8:19:33 AM: Started saving pip cache
8:19:33 AM: Finished saving pip cache
8:19:33 AM: Started saving emacs cask dependencies
8:19:33 AM: Finished saving emacs cask dependencies
8:19:33 AM: Started saving maven dependencies
8:19:33 AM: Finished saving maven dependencies
8:19:33 AM: Started saving boot dependencies
8:19:33 AM: Finished saving boot dependencies
8:19:34 AM: Started saving go dependencies
8:19:35 AM: Finished saving go dependencies
8:19:39 AM: Error running command: Build script returned non-zero exit code: 1
8:19:39 AM: Failing build: Failed to build site
8:19:39 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
8:19:39 AM: Finished processing build request in 2m10.478232047s

它似乎与 Node 版本有关,所以我尝试通过添加 a 来修复,.nvmrc但错误仍然存​​在。两者(本地和 Netlify)都在运行 Node version 12.16.3

当然,我也尝试在清理缓存的情况下进行构建。

这个问题没有提供更多信息,所以我有点迷茫。

4

1 回答 1

2

根据https://github.com/netlify/build/issues/1608,这是一个已知问题,应该在下一个 Netlify 版本中修复。version同时,您可以通过将字段package.json从更改为1来轻松修复它1.0.0

"version": "1.0.0",

这是因为,根据npm 文档

版本必须是可解析的node-semver,它与 npm 作为依赖项捆绑在一起。(npm install semver自己使用。)

于 2020-07-01T13:36:17.270 回答