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 SSR Issue: When attempting to execute npm run start, it appears that Express is not running to enable hot reload. #27440

Closed
1 task
julianguerrerop202 opened this issue Apr 10, 2024 · 4 comments

Comments

@julianguerrerop202
Copy link

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

It was working with Angular Universal

Description

You’ve encountered an issue where Angular SSR (Server-Side Rendering) isn’t executing your Express code when you run npm run start, but it works as expected when you run npm run build && npm run serve:ssr:<projectname>

Minimal Reproduction

First option:

The project is in this url: https://github.com/julianguerrerop202/testangularssr1

Or you could:

Create a project:

Create a new Angular project with SSR support using the following command

  1. ng new --ssr testangularssr1
  2. cd testangularssr1
  3. Choose Sass (SCSS) as your style format.

Add code:

To manage Express and its functionalities, we’ll start by adding a simple route and a console.log.
Open the server.ts file and add the following code snippet below the line server.set('views', browserDistFolder);

console.log(' == Express Works Well == ');
server.get('/required-page', (req, res) => {
    res.send('Successful!!');
});

Run serve:

When you run npm run start, I didn’t see the ’ == Express Works Well == ’ message. This suggests that Express might not be running. Additionally, attempting to access the route http://localhost:4200/required-page results in an error.

Exception or Error

ERROR RuntimeError: NG04002: Cannot match any routes. URL Segment: 'required-page'
    at Recognizer.noMatchError (/testangularssr1/node_modules/@angular/router/fesm2022/router.mjs:3694:12)
    at eval (/testangularssr1/node_modules/@angular/router/fesm2022/router.mjs:3727:20)
    at eval (/testangularssr1/node_modules/rxjs/dist/esm/internal/operators/catchError.js:10:39)
    at OperatorSubscriber.OperatorSubscriber._error (/testangularssr1/node_modules/rxjs/dist/esm/internal/operators/OperatorSubscriber.js:23:21)
    at OperatorSubscriber.error (/testangularssr1/node_modules/rxjs/dist/esm/internal/Subscriber.js:40:18)
    at OperatorSubscriber._error (/testangularssr1/node_modules/rxjs/dist/esm/internal/Subscriber.js:64:30)
    at OperatorSubscriber.error (/testangularssr1/node_modules/rxjs/dist/esm/internal/Subscriber.js:40:18)
    at OperatorSubscriber._error (/testangularssr1/node_modules/rxjs/dist/esm/internal/Subscriber.js:64:30)
    at OperatorSubscriber.error (/testangularssr1/node_modules/rxjs/dist/esm/internal/Subscriber.js:40:18)
    at OperatorSubscriber._error (/testangularssr1/node_modules/rxjs/dist/esm/internal/Subscriber.js:64:30) {
  code: 4002
}

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 17.3.3
Node: 20.11.1
Package Manager: npm 10.2.4
OS: darwin arm64

Angular: 17.3.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1703.3
@angular-devkit/build-angular   17.3.3
@angular-devkit/core            17.3.3
@angular-devkit/schematics      17.3.3
@schematics/angular             17.3.3
rxjs                            7.8.1
typescript                      5.4.4
zone.js                         0.14.4

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

This is expected as the server.ts is not used during ng serve.

Duplicate of #27144

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2024
@julianguerrerop202
Copy link
Author

@alan-agius4 In some comments like:
#26323 (comment)
I read that it will be fixed in future versions, is this true?

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Apr 10, 2024

@julianguerrerop202, #26323 is slightly different from #27144. We definitely want to fix this issue though.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants