问题
I am deploying an Angular app to Netlify. This app has deployed many times, and there have been no issues. Recently, while adding a new feature, I upgraded the app from Angular 5 to 7, and upgraded many dependencies. Now the build is failing with pretty minimal information.
On Netlify, the build commands I use are:
ng build --target=development --environment=staging
for dev and
ng build --target=production --environment=prod
for prod.
The log on Netlify is:
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
I notice that --target=
and --environment=
are not being processed. In past successful deployment logs, those options worked just fine. So I'm assuming the deployment issue is related to that.
Can anyone please offer some guidance on this?
Thank you.
回答1:
Check the docs for ng build command for latest Angular CLI commands.
These two options are missing:
3:55:25 PM: Unknown option: '--target'
3:55:25 PM: Unknown option: '--environment'
For --target
you can specify --prod=true
and for --environment
--configuration=production
(comes from angular.json file)
回答2:
I believe you can use the following arguments instead
for dev:
--configuration=development
--prod=false
for prod:
--configuration=production
--prod=true
You can also read about all the arguments that can be used here
来源:https://stackoverflow.com/questions/55032301/angular-7-app-deployment-ng-build-does-not-understand-target-or-environment