Skip to content

Nx compatibility #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
osnoser1 opened this issue Jul 20, 2024 · 5 comments · Fixed by #263
Closed

Nx compatibility #156

osnoser1 opened this issue Jul 20, 2024 · 5 comments · Fixed by #263
Labels

Comments

@osnoser1
Copy link

Is your feature request related to a problem? Please describe.
I'm trying to deploy an angular app with ssr using nx and netlify and I get an error because it doesn't find the angular.json file, and that is because the file was renamed to project.json file.

Describe the solution you'd like
Allow to specify the angular.json name or try to find a project.json file.

Additional context

Plugin "@netlify/angular-runtime" failed                      
9:19:03 PM: ────────────────────────────────────────────────────────────────
9:19:03 PM: ​
9:19:03 PM:   Error message
9:19:03 PM:   Error: Could not locate your angular.json at your project root or two levels above your publish directory. Make sure your publish directory is set to "{PATH_TO_YOUR_SITE}/dist/{YOUR_PROJECT_NAME}/browser", where {YOUR_PROJECT_NAME} is 'defaultProject' in your angular.json.
9:19:03 PM: ​
9:19:03 PM:   Plugin details
9:19:03 PM:   Package:        @netlify/angular-runtime
9:19:03 PM:   Version:        2.1.0
9:19:03 PM:   Repository:     git+https://github.com/netlify/angular-runtime.git
9:19:03 PM:   npm link:       https://www.npmjs.com/package/@netlify/angular-runtime
9:19:03 PM:   Report issues:  https://github.com/netlify/angular-runtime/issues
9:19:03 PM: ​
9:19:03 PM:   Error location
9:19:03 PM:   In "onPreBuild" event in "@netlify/angular-runtime" from Netlify app
9:19:03 PM: ​
9:19:03 PM:   Resolved config
9:19:03 PM:   build:
9:19:03 PM:     command: nx run sanity-example:build
9:19:03 PM:     commandOrigin: ui
9:19:03 PM:     publish: /opt/build/repo/dist/apps/sanity-example
9:19:03 PM:     publishOrigin: ui
9:19:03 PM:   plugins:
9:19:03 PM:     - inputs: {}
9:19:03 PM:       origin: ui
9:19:03 PM:       package: '@netlify/angular-runtime'
9:19:03 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:19:04 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
9:19:04 PM: Failing build: Failed to build site
@serhalp serhalp added the Angular label Sep 19, 2024 — with Linear
@macgors
Copy link

macgors commented Nov 29, 2024

+1
IMO this should be supported.

@osnoser1 Could I ask you how did you overcome this issue?

@osnoser1
Copy link
Author

osnoser1 commented Dec 2, 2024

+1 IMO this should be supported.

@osnoser1 Could I ask you how did you overcome this issue?

Hi @macgors, I applied a patch here to be able to deploy with nx: https://github.com/limitless-angular/limitless-angular/blob/main/patches/%40netlify__angular-runtime.patch

@gwesterman
Copy link

I recently encountered the same issue. Netlify automatically detects an Angular application and sets the deploy runtime to Angular, enabling the @netlify/angular-runtime plugin. However, this plugin is not compatible with Nx.

The solution is straightforward:

  1. Navigate to Site configurationBuild & deployBuild settings, then click Configure
  2. At the top, you will likely see Runtime: Angular and a Remove button
  3. Click Remove, then save the updated configuration

This hands back control over the build to you, the developer.

Below are the settings I am using:

Base directory: [empty] (appears as / after saving)
Package directory: apps/my-app
Build command: nx run my-app:build:production
Publish directory: dist/apps/my-app/browser

@Cephyric-gh
Copy link
Contributor

After figuring out a work around in 1 of our projects (I wrote a rough script that loops through every project.json that exists in the workspace and output an angular.json with them), I realised that there wasn't too much blocking NX from being supported by the runtime. Took a stab at it in #263.

As mentioned in the PR, it would be a cleaner DX/integration if packagePath was exposed to the runtime, as it currently has to enforce that the ANGULAR_PROJECT environment variable is set to the name of the project being deployed so it can build correct paths to the appropriate project.json, and assume the folder structure is unchanged from the default NX setup.

Very interested to hear thoughts!

@pieh pieh closed this as completed in #263 Mar 11, 2025
@pieh
Copy link
Contributor

pieh commented Mar 11, 2025

Thanks to @Cephyric-gh contribution - this should be now fixed in the 2.3.0 release ( https://github.com/netlify/angular-runtime/releases/tag/v2.3.0 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants