"Cannot find module" error when pre-rendering is on. #1452

Closed
opened 2025-08-09 17:20:12 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @astegmaier on 8/4/2016

I'm trying to get server-side-rendering working with a third-party component (wijmo flexgrid), but I'm running into trouble. I'm not sure if this is possible, but I seem to be hitting a very basic error that I think might be a more general problem--either a limitation in asp.net/node or an error on my part.

I can get things working in the Angular2Spa template, so long as I turn off server-side rendering (by removing the asp-prerender-module* tags from Index.cshtml in the template). However, when I turn server-side rendering back on and try to load in the browser, I get this error:

Exception: Call to Node module failed with error: Error: Cannot find module '../../../vendor/node_modules/wijmo/wijmo.angular2.grid'
at Function.Module._resolveFilename (module.js:325:15)

It seems that the following import statement (in ClientApp/components/grid-test/grid-test.component.ts) will resolve fine in the browser, but can't resolve on the server:

import { WjFlexGrid, WjFlexGridColumn } from '../../../vendor/node_modules/wijmo/wijmo.angular2.grid';

Does anyone have any ideas what could cause this type of error? I didn't change anything about load-client.ts or load-server.ts, so it's puzzling.

To see details about exactly what I'm doing, I cloned the template and made a simple repro--see my checkin here: 275449c390

Thanks in advance for any ideas!

*Originally created by @astegmaier on 8/4/2016* I'm trying to get server-side-rendering working with a third-party component ([wijmo flexgrid](http://demos.wijmo.com/5/Angular2/FlexGridIntro/FlexGridIntro/)), but I'm running into trouble. I'm not sure if this is possible, but I seem to be hitting a very basic error that I think might be a more general problem--either a limitation in asp.net/node or an error on my part. I can get things working in the Angular2Spa template, so long as I turn off server-side rendering (by removing the asp-prerender-module\* tags from Index.cshtml in the template). However, when I turn server-side rendering back on and try to load in the browser, I get this error: ``` Exception: Call to Node module failed with error: Error: Cannot find module '../../../vendor/node_modules/wijmo/wijmo.angular2.grid' at Function.Module._resolveFilename (module.js:325:15) ``` It seems that the following import statement (in ClientApp/components/grid-test/grid-test.component.ts) will resolve fine in the browser, but can't resolve on the server: `import { WjFlexGrid, WjFlexGridColumn } from '../../../vendor/node_modules/wijmo/wijmo.angular2.grid';` Does anyone have any ideas what could cause this type of error? I didn't change anything about load-client.ts or load-server.ts, so it's puzzling. To see details about exactly what I'm doing, I cloned the template and made a simple repro--see my checkin here: https://github.com/astegmaier/JavaScriptServices/commit/275449c39047630662ec27187210e20591787250 Thanks in advance for any ideas!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#1452
No description provided.