Visual Studio 2015: angular 2 template loading glitch
When using Visual Studio 2015 as an IDE, the following exception occurs when starting the project for the first time using the green "IIS Express" start debug button:
The exception is as follows:
An unhandled exception occurred while processing the request.
Exception: Call to Node module failed with error: Error: Cannot find module 'C:\Project\ClientApp\dist\main-server'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at findBootModule (C:\Project\node_modules\aspnet-prerendering\Prerendering.js:98:24)
at findBootFunc (C:\Project\node_modules\aspnet-prerendering\Prerendering.js:103:5)
at renderToString (C:\Project\node_modules\aspnet-prerendering\Prerendering.js:10:5)
at module.exports.renderToString (C:\Users\myuser\AppData\Local\Temp\tmpA8C3.tmp:19:46)
at C:\Users\myuser\AppData\Local\Temp\tmpA8C4.tmp:113:19
at IncomingMessage.<anonymous> (C:\Users\myuser\AppData\Local\Temp\tmpA8C4.tmp:132:38)
I believe this is due to Visual Studio 2015 opening the application in the browser before prerendering or Webpack is ready, as waiting for a few minutes and reloading the page clears the error and the application works beautifully.
The template works great with VS2015, thanks! 👍
Thanks for the report.
However I'm not sure what to make of it, since the file ClientApp\dist\main-server.js should already be on disk when you first created your project (it's bundled in the actual project template, so you don't even have to build it before the app can run).
That file does get regenerated when Webpack runs, but it just overwrites the existing build in place - there shouldn't be any period when the file doesn't exist on disk.
Is this something that just happened once for you, or does it happen every time you create a new project using the template?
Hi @SteveSandersonMS,
This happens only on the initial build after the project has been freshly checked out from source control or when the developer switches branches. It happens on all our developer machines. This could be related to generated .sln or .xproj file generated by VS2015 for the template. Should this be the case, I believe it might not be an issue with the generated templates itself and feel free to close this issue.
We do include ClientApp\dist\main-server.js as well as vendor.js in our source control as suggested by https://github.com/aspnet/JavaScriptServices/issues/312.
I've noticed in the build output from VS2015 that it skips compilation when the issue occurs: ------ Build started: Project: SeedApp, Configuration: Debug Any CPU ------ C:\Program Files\dotnet\dotnet.exe build "C:\Project" --configuration Debug --no-dependencies Project(.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation. ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Thank you for the feedback, the templates have improved greatly since the earlier versions, well done!
OK, thanks for clarifying. Since it sounds like it's not a problem with the template, I'll close this.