构建脚本返回非零退出代码:2 - React
Build script returned non-zero exit code: 2 - React
是的,我已经搜索了解决方案,但找不到如何使用 React 应用程序从 Netlify 部署我的网站。我的应用程序从 repo 分成客户端和服务器。我需要 运行 客户端文件夹。我也试过CI= npm 运行 build,把环境变量改成false,还有什么办法呢?这是日志。我也在本地 运行 构建。
Github 回购 - https://github.com/jerednav/mindful-list
10:41:33 PM: npm ERR! Missing script: "build"
10:41:33 PM: npm ERR!
10:41:33 PM: npm ERR! To see a list of scripts, run:
10:41:33 PM: npm ERR! npm run
10:41:33 PM: npm ERR! A complete log of this run can be found in:
10:41:33 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-11-20T06_41_33_126Z-debug.log
10:41:33 PM:
10:41:33 PM: ────────────────────────────────────────────────────────────────
10:41:33 PM: "build.command" failed
10:41:33 PM: ────────────────────────────────────────────────────────────────
10:41:33 PM:
10:41:33 PM: Error message
10:41:33 PM: Command failed with exit code 1: npm run build
10:41:33 PM:
10:41:33 PM: Error location
10:41:33 PM: In Build command from Netlify app:
10:41:33 PM: npm run build
10:41:33 PM:
10:41:33 PM: Resolved config
10:41:33 PM: build:
10:41:33 PM: command: npm run build
10:41:33 PM: commandOrigin: ui
10:41:33 PM: environment:
10:41:33 PM: - CI
10:41:33 PM: publish: /opt/build/repo/build
10:41:33 PM: publishOrigin: ui
10:41:33 PM: Caching artifacts
10:41:33 PM: Started saving node modules
10:41:33 PM: Finished saving node modules
10:41:33 PM: Started saving build plugins
10:41:33 PM: Finished saving build plugins
10:41:33 PM: Started saving pip cache
10:41:33 PM: Finished saving pip cache
10:41:33 PM: Started saving emacs cask dependencies
10:41:33 PM: Finished saving emacs cask dependencies
10:41:33 PM: Started saving maven dependencies
10:41:33 PM: Finished saving maven dependencies
10:41:33 PM: Started saving boot dependencies
10:41:33 PM: Finished saving boot dependencies
10:41:33 PM: Started saving rust rustup cache
10:41:33 PM: Finished saving rust rustup cache
10:41:33 PM: Started saving go dependencies
10:41:33 PM: Finished saving go dependencies
10:41:36 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:41:36 PM: Creating deploy upload records
10:41:36 PM: Failing build: Failed to build site
10:41:36 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
10:41:36 PM: Finished processing build request in 14.470081767s
您需要在 netlify 设置中指定基本目录。
转到设置 -> 构建和部署 -> 编辑设置并填写 client
.
或者您可以使用以下配置在项目目录中创建 netlify.toml
[build]
# Directory to change to before starting a build.
# This is where we will look for package.json/.nvmrc/etc.
# If not set, defaults to the root directory.
base = "client"
是的,我已经搜索了解决方案,但找不到如何使用 React 应用程序从 Netlify 部署我的网站。我的应用程序从 repo 分成客户端和服务器。我需要 运行 客户端文件夹。我也试过CI= npm 运行 build,把环境变量改成false,还有什么办法呢?这是日志。我也在本地 运行 构建。
Github 回购 - https://github.com/jerednav/mindful-list
10:41:33 PM: npm ERR! Missing script: "build"
10:41:33 PM: npm ERR!
10:41:33 PM: npm ERR! To see a list of scripts, run:
10:41:33 PM: npm ERR! npm run
10:41:33 PM: npm ERR! A complete log of this run can be found in:
10:41:33 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-11-20T06_41_33_126Z-debug.log
10:41:33 PM:
10:41:33 PM: ────────────────────────────────────────────────────────────────
10:41:33 PM: "build.command" failed
10:41:33 PM: ────────────────────────────────────────────────────────────────
10:41:33 PM:
10:41:33 PM: Error message
10:41:33 PM: Command failed with exit code 1: npm run build
10:41:33 PM:
10:41:33 PM: Error location
10:41:33 PM: In Build command from Netlify app:
10:41:33 PM: npm run build
10:41:33 PM:
10:41:33 PM: Resolved config
10:41:33 PM: build:
10:41:33 PM: command: npm run build
10:41:33 PM: commandOrigin: ui
10:41:33 PM: environment:
10:41:33 PM: - CI
10:41:33 PM: publish: /opt/build/repo/build
10:41:33 PM: publishOrigin: ui
10:41:33 PM: Caching artifacts
10:41:33 PM: Started saving node modules
10:41:33 PM: Finished saving node modules
10:41:33 PM: Started saving build plugins
10:41:33 PM: Finished saving build plugins
10:41:33 PM: Started saving pip cache
10:41:33 PM: Finished saving pip cache
10:41:33 PM: Started saving emacs cask dependencies
10:41:33 PM: Finished saving emacs cask dependencies
10:41:33 PM: Started saving maven dependencies
10:41:33 PM: Finished saving maven dependencies
10:41:33 PM: Started saving boot dependencies
10:41:33 PM: Finished saving boot dependencies
10:41:33 PM: Started saving rust rustup cache
10:41:33 PM: Finished saving rust rustup cache
10:41:33 PM: Started saving go dependencies
10:41:33 PM: Finished saving go dependencies
10:41:36 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:41:36 PM: Creating deploy upload records
10:41:36 PM: Failing build: Failed to build site
10:41:36 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
10:41:36 PM: Finished processing build request in 14.470081767s
您需要在 netlify 设置中指定基本目录。
转到设置 -> 构建和部署 -> 编辑设置并填写 client
.
或者您可以使用以下配置在项目目录中创建 netlify.toml
[build]
# Directory to change to before starting a build.
# This is where we will look for package.json/.nvmrc/etc.
# If not set, defaults to the root directory.
base = "client"