netlify / angular-runtime

The Angular Runtime allows Angular to run on Netlify with zero configuration
https://docs.netlify.com/integrations/frameworks/angular/
MIT License
18 stars 7 forks source link

Deploy Angular 17 SSR / SSG fails #93

Closed kreuzerk closed 5 months ago

kreuzerk commented 7 months ago

Describe the bug Hi there I generated a new Angular 17 application with the following command:

ng new my-app --ssr

I followed the instructions from this blog post: https://www.netlify.com/blog/deploy-your-angular-v17-apps-to-netlify/. Unfortunately I got the following error during deployment.

5:26:57 PM: Netlify Build                                                 
5:26:57 PM: ────────────────────────────────────────────────────────────────
5:26:57 PM: ​
5:26:57 PM: ❯ Version
5:26:57 PM:   @netlify/build 29.29.4
5:26:57 PM: ​
5:26:57 PM: ❯ Flags
5:26:57 PM:   baseRelDir: true
5:26:57 PM:   buildId: 656dfdadb754b6133966f29c
5:26:57 PM:   deployId: 656dfdadb754b6133966f29e
5:26:57 PM: ​
5:26:57 PM: ❯ Current directory
5:26:57 PM:   /opt/build/repo
5:26:57 PM: ​
5:26:57 PM: ❯ Config file
5:26:57 PM:   No config file was defined: using default values.
5:26:57 PM: ​
5:26:57 PM: ❯ Context
5:26:57 PM:   production
5:26:57 PM: ​
5:26:57 PM: ❯ Installing plugins
5:26:57 PM:    - @netlify/angular-runtime@2.0.4
5:26:58 PM: ​
5:26:58 PM: ❯ Loading plugins
5:26:58 PM:    - @netlify/angular-runtime@2.0.4 from Netlify app
5:26:59 PM: ​
5:26:59 PM: @netlify/angular-runtime (onPreBuild event)                   
5:26:59 PM: ────────────────────────────────────────────────────────────────
5:26:59 PM: ​
5:26:59 PM: ​
5:26:59 PM: (@netlify/angular-runtime onPreBuild completed in 10ms)
5:26:59 PM: ​
5:26:59 PM: Build command from Netlify app                                
5:26:59 PM: ────────────────────────────────────────────────────────────────
5:26:59 PM: ​
5:26:59 PM: $ npm run build
5:26:59 PM: > nothing-special@0.0.0 build
5:26:59 PM: > ng build
5:27:00 PM: - Building...
5:27:11 PM: An unexpected error occurred: [object Object]
5:27:11 PM: ​
5:27:11 PM: "build.command" failed                                        
5:27:11 PM: ────────────────────────────────────────────────────────────────
5:27:11 PM: ​
5:27:11 PM:   Error message
5:27:11 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
5:27:11 PM: ​
5:27:11 PM:   Error location
5:27:11 PM:   In Build command from Netlify app:
5:27:11 PM:   npm run build
5:27:11 PM: ​
5:27:11 PM:   Resolved config
5:27:11 PM:   build:
5:27:11 PM:     command: npm run build
5:27:11 PM:     commandOrigin: ui
5:27:11 PM:     publish: /opt/build/repo/dist/nothing-special/browser
5:27:11 PM:     publishOrigin: ui
5:27:11 PM:   plugins:
5:27:11 PM:     - inputs: {}
5:27:11 PM:       origin: ui
5:27:11 PM:       package: "@netlify/angular-runtime"
5:27:11 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:27:11 PM: Failing build: Failed to build site
5:27:12 PM: Failed during stage "building site": Build script returned non-zero exit code: 2
5:27:12 PM: Finished processing build request in 39.131s

To Reproduce Steps to reproduce the behavior:

  1. Generate a new Angular application
  2. Push to repo
  3. Setup Netlify deployment with defaults
  4. See error in Deployment log on build step

Expected behavior We deploy a Angular application with SSR and SSG (hypbrid)

Versions

Dashiman commented 7 months ago

Have the same problem

Skn0tt commented 5 months ago

Hey folks! Sorry for not reacting earlier on this. It seems to me that this is related to https://github.com/angular/angular-cli/issues/26648, and a bug in the Angular build process that's triggered by Node.js 18.19.0. To work around this, you can either upgrade your version of Angular, or switch your site to use Node.js 20: https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript

Skn0tt commented 5 months ago

I've tested this locally and this workaround worked for me, so i'll go ahead and close this issue. If the workarounds mentioned don't solve the issue, please leave another comment and i'll dig deeper!