0

我正在将 Angular 应用程序部署到 Netlify。这个应用程序已经部署了很多次,并且没有出现任何问题。最近,在添加新功能的同时,我将应用程序从 Angular 5 升级到 7,并升级了许多依赖项。现在构建失败了,信息很少。

在 Netlify 上,我使用的构建命令是: ng build --target=development --environment=stagingfor dev 和 ng build --target=production --environment=prodfor prod。

Netlify 上的日志是:

3:54:11 PM: Fetching cached dependencies
3:54:11 PM: Starting to download cache of 99.4MB
3:54:12 PM: Finished downloading cache in 773.818516ms
3:54:12 PM: Starting to extract cache
3:54:17 PM: Finished extracting cache in 4.66127562s
3:54:17 PM: Finished fetching cache in 5.479273794s
3:54:17 PM: Starting to prepare the repo for build
3:54:17 PM: Preparing Git Reference pull/102/head
3:54:18 PM: Starting build script
3:54:18 PM: Installing dependencies
3:54:19 PM: Started restoring cached node version
3:54:21 PM: Finished restoring cached node version
3:54:21 PM: v8.15.1 is already installed.
3:54:22 PM: Now using node v8.15.1 (npm v6.4.1)
3:54:23 PM: Attempting ruby version 2.3.6, read from environment
3:54:24 PM: Using ruby version 2.3.6
3:54:24 PM: Using PHP version 5.6
3:54:24 PM: Started restoring cached node modules
3:54:24 PM: Finished restoring cached node modules
3:54:24 PM: Installing NPM modules using NPM version 6.4.1
3:55:17 PM: > node-sass@4.11.0 install /opt/build/repo/node_modules/node-sass
3:55:17 PM: > node scripts/install.js
3:55:17 PM: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.11.0/linux-x64-57_binding.node
3:55:18 PM: Download complete
3:55:18 PM: Binary saved to /opt/build/repo/node_modules/node-sass/vendor/linux-x64-57/binding.node
3:55:18 PM: Caching binary to /opt/buildhome/.npm/node-sass/4.11.0/linux-x64-57_binding.node
3:55:19 PM: > node-sass@4.11.0 postinstall /opt/build/repo/node_modules/node-sass
3:55:19 PM: > node scripts/build.js
3:55:19 PM: Binary found at /opt/build/repo/node_modules/node-sass/vendor/linux-x64-57/binding.node
3:55:19 PM: Testing binary
3:55:19 PM: Binary is fine
3:55:22 PM: npm WARN
3:55:22 PM: optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/webpack-dev-server/node_modules/fsevents):
3:55:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
3:55:22 PM: npm WARN optional
3:55:22 PM:  SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
3:55:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
3:55:22 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/@angular/compiler-cli/node_modules/fsevents):
3:55:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
3:55:22 PM: npm
3:55:22 PM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/@angular-devkit/core/node_modules/fsevents):
3:55:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
3:55:22 PM: added 561 packages from 247 contributors, removed 635 packages, updated 323 packages and audited 36240 packages in 57.022s
3:55:22 PM: found 0 vulnerabilities
3:55:23 PM: NPM modules installed
3:55:23 PM: Started restoring cached go cache
3:55:23 PM: Finished restoring cached go cache
3:55:23 PM: unset GOOS;
3:55:23 PM: unset GOARCH;
3:55:23 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.10.linux.amd64';
3:55:23 PM: export PATH="/opt/buildhome/.gimme/versions/go1.10.linux.amd64/bin:${PATH}";
3:55:23 PM: go version >&2;
3:55:23 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.10.linux.amd64.env';
3:55:23 PM: go version go1.10 linux/amd64
3:55:23 PM: Installing missing commands
3:55:23 PM: Verify run directory
3:55:23 PM: Executing user command: ng build --target=development --environment=staging
3:55:25 PM: Unknown option: '--target'
3:55:25 PM: Unknown option: '--environment'
3:55:25 PM: Caching artifacts
3:55:25 PM: Started saving node modules
3:55:25 PM: Finished saving node modules
3:55:25 PM: Started saving pip cache
3:55:25 PM: Finished saving pip cache
3:55:25 PM: Started saving emacs cask dependencies
3:55:25 PM: Finished saving emacs cask dependencies
3:55:25 PM: Started saving maven dependencies
3:55:25 PM: Finished saving maven dependencies
3:55:25 PM: Started saving boot dependencies
3:55:25 PM: Finished saving boot dependencies
3:55:25 PM: Started saving go dependencies
3:55:25 PM: Finished saving go dependencies
3:55:25 PM: Error running command: Build script returned non-zero exit code: 1
3:55:25 PM: Failing build: Failed to build site
3:55:29 PM: Finished processing build request in 1m20.618386048s
3:55:30 PM: Shutting down logging, 0 messages pending

我注意到了,--target=并且--environment=没有被处理。在过去成功的部署日志中,这些选项工作得很好。所以我假设部署问题与此有关。

任何人都可以提供一些指导吗?

谢谢你。

4

2 回答 2

5

检查 ng build 命令的文档以获取最新的 Angular CLI 命令。

缺少这两个选项:

3:55:25 PM: Unknown option: '--target'
3:55:25 PM: Unknown option: '--environment'

因为--target你可以指定--prod=true

和 for --environment --configuration=production(来自 angular.json 文件)

于 2019-03-06T21:26:43.220 回答
2

我相信您可以改用以下参数

对于开发:

--configuration=development
--prod=false

产品:

--configuration=production 
--prod=true

您还可以在此处阅读有关可以使用的所有参数

于 2019-03-06T21:26:57.310 回答