由于构建问题,我的 Netlify 部署失败: 我正在尝试直接从我的 Github 存储库部署此站点。
这是完整的日志:
4:03:47 PM: Build ready to start
4:03:49 PM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
4:03:49 PM: build-image tag: v3.7.6
4:03:49 PM: buildbot version: 96f6c6faf398b8f2b7e39c2c3c6a03ac4592e535
4:03:49 PM: Fetching cached dependencies
4:03:49 PM: Failed to fetch cache, continuing with build
4:03:49 PM: Starting to prepare the repo for build
4:03:50 PM: No cached dependencies found. Cloning fresh repo
4:03:50 PM: git clone https://github.com/Ashumaurya/sorting
4:03:50 PM: Preparing Git Reference refs/heads/master
4:03:51 PM: Parsing package.json dependencies
4:03:52 PM: Starting build script
4:03:52 PM: Installing dependencies
4:03:52 PM: Python version set to 2.7
4:03:53 PM: Downloading and installing node v10.11.0...
4:03:53 PM: Downloading https://nodejs.org/dist/v10.11.0/node-v10.11.0-linux-x64.tar.xz...
4:03:54 PM: Computing checksum with sha256sum
4:03:54 PM: Checksums matched!
4:03:56 PM: Now using node v10.11.0 (npm v6.4.1)
4:03:56 PM: Started restoring cached build plugins
4:03:56 PM: Finished restoring cached build plugins
4:03:56 PM: Attempting ruby version 2.7.1, read from environment
4:03:57 PM: Using ruby version 2.7.1
4:03:57 PM: Using PHP version 5.6
4:03:57 PM: Started restoring cached node modules
4:03:57 PM: Finished restoring cached node modules
4:03:58 PM: Installing NPM modules using NPM version 6.4.1
4:04:24 PM: > core-js@2.6.12 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
4:04:25 PM: > node -e "try{require('./postinstall')}catch(e){}"
4:04:25 PM: > core-js@3.8.2 postinstall /opt/build/repo/node_modules/core-js
4:04:25 PM: > node -e "try{require('./postinstall')}catch(e){}"
4:04:25 PM: > core-js-pure@3.8.2 postinstall /opt/build/repo/node_modules/core-js-pure
4:04:25 PM: > node -e "try{require('./postinstall')}catch(e){}"
4:04:25 PM: > ejs@2.7.4 postinstall /opt/build/repo/node_modules/ejs
4:04:25 PM: > node ./postinstall.js
4:04:27 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
4:04:27 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
4:04:27 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
4:04:27 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
4:04:27 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/fsevents):
4:04:27 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
4:04:27 PM: added 1979 packages from 762 contributors and audited 1982 packages in 28.912s
4:04:27 PM: found 1269 vulnerabilities (170 moderate, 1099 high)
4:04:27 PM: run `npm audit fix` to fix them, or `npm audit` for details
4:04:27 PM: NPM modules installed
4:04:27 PM: Started restoring cached go cache
4:04:27 PM: Finished restoring cached go cache
4:04:27 PM: go version go1.14.4 linux/amd64
4:04:27 PM: go version go1.14.4 linux/amd64
4:04:27 PM: Installing missing commands
4:04:27 PM: Verify run directory
4:04:29 PM:
4:04:29 PM: ────────────────────────────────────────────────────────────────
4:04:29 PM: Netlify Build
4:04:29 PM: ────────────────────────────────────────────────────────────────
4:04:29 PM:
4:04:29 PM: ❯ Version
4:04:29 PM: @netlify/build 11.18.0
4:04:29 PM:
4:04:29 PM: ❯ Flags
4:04:29 PM: deployId: 60aa2f8b1d35c500072a653d
4:04:29 PM:
4:04:29 PM: ❯ Current directory
4:04:29 PM: /opt/build/repo
4:04:29 PM:
4:04:29 PM: ❯ Config file
4:04:29 PM: /opt/build/repo/netlify.toml
4:04:29 PM:
4:04:29 PM: ❯ Context
4:04:29 PM: production
4:04:29 PM:
4:04:29 PM: ────────────────────────────────────────────────────────────────
4:04:29 PM: 1. Build command from Netlify app
4:04:29 PM: ────────────────────────────────────────────────────────────────
4:04:29 PM:
4:04:29 PM: $ npm run build
4:04:29 PM: > sorting@0.1.0 build /opt/build/repo
4:04:29 PM: > react-scripts build
4:04:31 PM: Creating an optimized production build...
4:04:42 PM: Failed to compile.
4:04:42 PM:
4:04:42 PM: createRequire is not a function
4:04:42 PM: Referenced from: BaseConfig
4:04:42 PM: npm ERR! code ELIFECYCLE
4:04:42 PM: npm ERR! errno 1
4:04:42 PM: npm ERR! sorting@0.1.0 build: `react-scripts build`
4:04:42 PM: npm ERR! Exit status 1
4:04:42 PM: npm ERR!
4:04:42 PM: npm ERR! Failed at the sorting@0.1.0 build script.
4:04:42 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
4:04:42 PM: npm ERR! A complete log of this run can be found in:
4:04:42 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-05-23T10_34_42_160Z-debug.log
4:04:42 PM:
4:04:42 PM: ────────────────────────────────────────────────────────────────
4:04:42 PM: "build.command" failed
4:04:42 PM: ────────────────────────────────────────────────────────────────
4:04:42 PM:
4:04:42 PM: Error message
4:04:42 PM: Command failed with exit code 1: npm run build
4:04:42 PM:
4:04:42 PM: Error location
4:04:42 PM: In Build command from Netlify app:
4:04:42 PM: npm run build
4:04:42 PM:
4:04:42 PM: Resolved config
4:04:42 PM: build:
4:04:42 PM: command: npm run build
4:04:42 PM: commandOrigin: ui
4:04:42 PM: environment:
4:04:42 PM: - NODE_VERSION
4:04:42 PM: - YARN_VERSION
4:04:42 PM: - NPM_VERSION
4:04:42 PM: publish: /opt/build/repo/build
4:04:42 PM: Caching artifacts
4:04:42 PM: Started saving node modules
4:04:42 PM: Finished saving node modules
4:04:42 PM: Started saving build plugins
4:04:42 PM: Finished saving build plugins
4:04:42 PM: Started saving pip cache
4:04:42 PM: Finished saving pip cache
4:04:42 PM: Started saving emacs cask dependencies
4:04:42 PM: Finished saving emacs cask dependencies
4:04:42 PM: Started saving maven dependencies
4:04:42 PM: Finished saving maven dependencies
4:04:42 PM: Started saving boot dependencies
4:04:42 PM: Finished saving boot dependencies
4:04:42 PM: Started saving rust rustup cache
4:04:42 PM: Finished saving rust rustup cache
4:04:42 PM: Started saving go dependencies
4:04:42 PM: Finished saving go dependencies
4:04:45 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:04:45 PM: Creating deploy upload records
4:04:46 PM: Failing build: Failed to build site
4:04:46 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
4:04:46 PM: Finished processing build request in 56.362135788s
这里是我的 Package.json :
{
"name": "sorting",
"version": "0.1.0",
"private": true,
"dependencies": {
"@babel/core": "^7.14.3",
"@testing-library/jest-dom": "^5.11.8",
"@testing-library/react": "^11.2.3",
"@testing-library/user-event": "^12.6.0",
"babel-eslint": "^10.1.0",
"emailjs-com": "^2.6.4",
"eslint-config-react-app": "^6.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1",
"typescript": "^4.2.4",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
我尝试了几件事,但没有奏效。如果有人可以向我解释错误是什么以及如何解决它,那将非常有帮助。 谢谢你
答案 0 :(得分:1)
似乎节点版本 v10.11.0
是问题所在。
你所要做的就是,
<块引用>或者设置一个高于 10.12.0 的 NODE_VERSION 环境变量
或
<块引用>将 .node-version 或 .nvmrc 文件添加到存储库中站点的基本目录并指定更高版本。
配置构建(Netlify):https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript
或
使用 netlify.toml
文件并指定如下所示。
[build.environment]
NODE_VERSION = "14.17.0"