Skip to content
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

Angular, React, and Vue sample. #76

Merged
merged 3 commits into from
Jan 11, 2024

Conversation

IEvangelist
Copy link
Member

@IEvangelist IEvangelist commented Jan 4, 2024

A sample that shows how to use .NET Aspire with Angular, React, and Vue.

.NET Aspire dashboard

image

Angular app

image

React app

image

Vue app

image

@OwenCross289
Copy link

When checking out this commit, I followed the readme, ran npm install for all 3 of the JS projects. When running the Aspire AppHost project, the Angular app fails to start: it gets a NaN as a port, with this logged.

> [email protected] start
> ng serve --port %PORT%
Node.js version v21.1.0 detected.
Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/previous-releases/.
/Users/owen/Developer/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/node_modules/rxjs/dist/cjs/internal/util/reportUnhandledError.js:13
            throw err;
            ^
RangeError [ERR_SOCKET_BAD_PORT]: options.port should be >= 0 and < 65536. Received type number (NaN).
    at validatePort (node:internal/validators:424:11)
    at Server.listen (node:net:2000:5)
    at /Users/owen/Developer/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/node_modules/@angular-devkit/build-angular/src/utils/check-port.js:55:14
    at new Promise (<anonymous>)
    at checkPort (/Users/owen/Developer/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/node_modules/@angular-devkit/build-angular/src/utils/check-port.js:27:12)
    at initialize (/Users/owen/Developer/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/node_modules/@angular-devkit/build-angular/src/builders/dev-server/builder.js:112:63) {
  code: 'ERR_SOCKET_BAD_PORT'
}
Node.js v21.1.0

Set up:
Aspire preview 2 workload installed.
Running through dotnet run in AppHost proj
MacOs: 14.2.1
Node: v21.1.0
npm ng --version: 10.2.3

Sorry if I am being too early on this

@IEvangelist
Copy link
Member Author

When checking out this commit, I followed the readme, ran npm install for all 3 of the JS projects. When running the Aspire AppHost project, the Angular app fails to start: it gets a NaN as a port, with this logged.

> [email protected] start
> ng serve --port %PORT%
Node.js version v21.1.0 detected.
Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/previous-releases/.
/Users/owen/Developer/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/node_modules/rxjs/dist/cjs/internal/util/reportUnhandledError.js:13
            throw err;
            ^
RangeError [ERR_SOCKET_BAD_PORT]: options.port should be >= 0 and < 65536. Received type number (NaN).
    at validatePort (node:internal/validators:424:11)
    at Server.listen (node:net:2000:5)
    at /Users/owen/Developer/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/node_modules/@angular-devkit/build-angular/src/utils/check-port.js:55:14
    at new Promise (<anonymous>)
    at checkPort (/Users/owen/Developer/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/node_modules/@angular-devkit/build-angular/src/utils/check-port.js:27:12)
    at initialize (/Users/owen/Developer/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/node_modules/@angular-devkit/build-angular/src/builders/dev-server/builder.js:112:63) {
  code: 'ERR_SOCKET_BAD_PORT'
}
Node.js v21.1.0

Set up: Aspire preview 2 workload installed. Running through dotnet run in AppHost proj MacOs: 14.2.1 Node: v21.1.0 npm ng --version: 10.2.3

Sorry if I am being too early on this

Ah, I think that might be an issue with Windows. I passed the port to the ng serve --port switch using %PORT%, if you're not on Windows that won't work... Try changing that to ng serve --port $PORT instead.

@OwenCross289
Copy link

When checking out this commit, I followed the readme, ran npm install for all 3 of the JS projects. When running the Aspire AppHost project, the Angular app fails to start: it gets a NaN as a port, with this logged.

[email protected] start

ng serve --port %PORT%

Node.js version v21.1.0 detected.

Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/previous-releases/.

/Users/owen/Developer/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/node_modules/rxjs/dist/cjs/internal/util/reportUnhandledError.js:13

        throw err;
        ^

RangeError [ERR_SOCKET_BAD_PORT]: options.port should be >= 0 and < 65536. Received type number (NaN).

at validatePort (node:internal/validators:424:11)
at Server.listen (node:net:2000:5)
at /Users/owen/Developer/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/node_modules/@angular-devkit/build-angular/src/utils/check-port.js:55:14
at new Promise (<anonymous>)
at checkPort (/Users/owen/Developer/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/node_modules/@angular-devkit/build-angular/src/utils/check-port.js:27:12)
at initialize (/Users/owen/Developer/aspire-samples/samples/AspireWithJavaScript/AspireJavaScript.Angular/node_modules/@angular-devkit/build-angular/src/builders/dev-server/builder.js:112:63) {

code: 'ERR_SOCKET_BAD_PORT'

}

Node.js v21.1.0

Set up: Aspire preview 2 workload installed. Running through dotnet run in AppHost proj MacOs: 14.2.1 Node: v21.1.0 npm ng --version: 10.2.3

Sorry if I am being too early on this

Ah, I think that might be an issue with Windows. I passed the port to the ng serve --port switch using %PORT%, if you're not on Windows that won't work... Try changing that to ng serve --port $PORT instead.

That, fixed it! Thanks!

@IEvangelist
Copy link
Member Author

Hey @OwenCross289 - I fixed the issue by using run-script-os, thanks for catching this!

Copy link
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I do wonder whether we could make these projects show up in VS via the esproj project types.

@IEvangelist
Copy link
Member Author

LGTM. I do wonder whether we could make these projects show up in VS via the esproj project types.

Yeah, that would be really cool!

@mitchdenny mitchdenny merged commit ef6868b into dotnet:main Jan 11, 2024
3 checks passed
meneasysoft pushed a commit to meneasysoft/aspire-samples that referenced this pull request Jul 25, 2024
* Angular, React, and Vue sample.

* Add run-script-os to use the appropriate switch for env var

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

Successfully merging this pull request may close these issues.

3 participants