-
Notifications
You must be signed in to change notification settings - Fork 483
Express Engine returns a 'file not found' error with Angular 9 RC 1, Universal Next 6 #1327
Comments
Hi, I tried to reproduce locally and didn't manage. Can you please share a reproduction? Also, are you update from an Angular 8 application? If that's the case, did you run Thanks. |
I tried to do a minimal reproduction and didn't encounter the issue. Apparently it's something specific to my configuration. I was, in fact, upgrading from Angular 8 and did the migration, but the migration is extremely optimistic (it assumes that I can use the I did however incorporate what seem to be the major changes I've noticed so far going from 8 -> 9.
With those changes, I still get this error at the location I mentioned in the "Is there anything else we should know?" section. |
Hi - I think Point no.2 you mentioned is the issue
You are ending up with JIT mode which is probably not what you intended. Can you share how you are building the server bundle. We need to make sure the server build is using AOT mode. |
@vikerman Here is my Angular.json https://gist.github.com/justinappler/aa371fcb9f2fcbbfd1aca071d1c6f95e To clarify, in v9, I should be using the |
By any chance are you still using the webpack node script to compile your
server.ts?
I also noticed that the server builder options are not updated.
Take a look at an example here:
https://github.com/angular/universal/blob/b14ca211780f07ade0424a21e2f604319aa47d75/integration/express-engine-ivy/angular.json#L154
…On Wed, 20 Nov 2019 at 20:35, Justin Appler ***@***.***> wrote:
@vikerman <https://github.com/vikerman> Here is my Angular.json
https://gist.github.com/justinappler/aa371fcb9f2fcbbfd1aca071d1c6f95e
To clarify, in v9, I should be using the ServerAppModule, correct? Are
you saying that modules can be built either in JIT or AOT mode in v9?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1327?email_source=notifications&email_token=AEF74WRCRO6NEAGKLYLWY23QUWGRDA5CNFSM4JLBOHSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEUFOEQ#issuecomment-556291858>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEF74WVWEKH4QE7ZUK6U4ADQUWGRDANCNFSM4JLBOHSA>
.
|
I think what is happening is that you are compiling your server app entirely with webpack ts-loader which is ending up being compiled in JIT mode. In v9, the external webpack-cli part was removed and is now part of During v9 update there are also a couple of changes apart from the changes mentioned above. These are;
I would strongly recommend to use Also, are you using Ivy or VE? |
@alan-agius4 So I'm actually building the server bundle with the CLI using the It's not trivial for us to just move all the express server code we wrote over to the I think I'm using Ivy, in that I'm using 9.0 and not turning Ivy off in the tsconfig. It seems possible though, per @vikerman 's comment, that my server bundle is not getting built in AOT mode (hence why it can't find the template files). |
I have a hunch on what's happening. Since you are using the CLI to build your server, your build is AOT because in the CLI we don't offer a way to build a server in JIT mode. What I think is happening is that you are fall backing to JIT mode during runtime. I am going to assume a couple of things and kindly correct me if this is not the case in your project.
Node is unable to resolve the entrypoints generated by NGCC integration with the CLI. Since such entrypoints are created to be used by bundlers. One example of such entrypoints is the To keep your existing setup with a separate webpack compilation with ts-loader for your You need to do a couple of things:
Nb: After doing the above changes you need to nuke your
With this approach the entrypoints will be overridden with the Ivy equivalent which will cause Node to be able to resolve such entrypoints during runtime. |
Hi @alan-agius4 , I followed the steps you suggested, and did the following: Modified the server target and set My package.json already had a
This command runs fine. However, when I modified it to be simply
If I clear Also, just want to say that I really appreciate your help in debugging this and providing so much direct assistance. |
The below NGCC binary call will only work if you use the CLI to bundle all your bundles.
Note: that now we removed this has been removed and no longer gets added in project when they migrate. The |
Any luck with RC 3? |
@alan-agius4 Same error unfortunately. I've started focusing my efforts on trying to move code out of the express server so that I can build it without a customized Webpack config (and thus move it under the purview of the CLI). |
Awesome, if you have any questions or queries let me know 😊 |
@alan-agius4 So I've now done the needed changes to get our app to use the CLI to build the server. The compilation looks like it worked fine (I get a single main.js bundle now that starts the express server properly). That said, the issue persists 😞 (rendering a page errors with an inability to fine a template HTML file). One thing I've noticed: the CLI seems to be doing a replacement of |
That replacement is done by webpack it reflects the mode that webpack is running. To enable prod modeyou need to enable the optimization option:
That being said, dev/prod mode shouldn’t cause that error. |
@alan-agius4 Interestingly, switching to |
Can you kindly send a snippet of the compiled a component/module ideally without optimizations please? |
@alan-agius4 Here you go: https://drive.google.com/file/d/1VX2Qp6sbsFT6O-I9IAhRj5xJy505HzL7/view?usp=sharing Also happy to jump on a Hangout/Zoom or something if it helps, just let me know (you can reach out directly at justin (at) crunchbase.com) |
@justinappler, thanks for the above. Let me go through that and will reach out to you in a day or two. Thanks once again. |
Bdw, I couldn't help but notice but |
@alan-agius4 It's definitely in there, I think Google Drive lazy loads the document as you scroll through: |
Silly me you are right, I'll download it and review it tomorrow. Thanks once again for your copereration. |
2 questions;
/***/ "@angular/core":
/*!********************************!*\
!*** external "@angular/core" ***!
\********************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = require("@angular/core");
/***/ }),
Thanks before hand. |
Note: if remove |
Progress! When I change the
So, if I'm not bundling dependencies (which I'd prefer not to for build speed and such), it seems I'll need to keep the postinstall script as it is above? |
Yes that is correct. |
Indeed the error you are seeing doesn’t seem to be related to this issue. And now you are running in Ivy mode. |
OK, thats seems very doable.
Excellent, I'll look into that issue separately. Hopefully after that I can get a sense of the SSR performance with Ivy! Thanks for your help! |
Closing as the original error seems to have been resolved. Please feel free to open a new issue, if you have any further problems. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report
When serving requests using the express engine and a ServerAppModule built with CLI/Core 9 RC1, the express engine callback contains an error that the component template file cannot be found.
What is the expected behavior?
Engine returns HTML
What is the current behavior?
Engine returns the following error:
Error: ENOENT: no such file or directory, open 'auth-to-contribute.component.html'
(where the component file is part of the ServerAppModule).
What modules are related to this issue?
Minimal reproduction with instructions:
Don't have a minimal repro case unfortunately.
Environment:
@nguniversal versions
Is there anything else we should know?
I started following the stacktrace for where this error is triggered, and it seems to be the if block in
_preParseTemplate
indirective_normalizer.ts
(it ultimately fails to fetch the template). Interestingly, this doesn't appear to be a problem for library component templates (Material2 components don't try to fetch the template as its part of thePrenormalizedTemplateMetadata
). For the components internal to my app, however, it tries and fails to find them on the filesystem.The text was updated successfully, but these errors were encountered: