CoreTemplatePack icon indicating copy to clipboard operation
CoreTemplatePack copied to clipboard

window is not defined

Open AbrarJahin opened this issue 8 years ago • 1 comments

Installed product versions

  • Visual Studio: 2015 community
  • This extension: 1.1.21

Description

I am a trying to use this template and tried to upgrade it to 2.4, but there is some difficulties, so I decided to use Angular 2.1.0. The styling was not working, so I have added this-

https://github.com/abrarjahin/Dot.NetCore_Angular2_App/commit/be93036beb791600a52fd9abd34001b38033e240

Now I am having some error like this-

An unhandled exception occurred while processing the request.

Exception: Call to Node module failed with error: Prerendering failed because of error: ReferenceError: window is not defined
at D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:6541
at D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:6473
at e.exports (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:6759)
at Object.<anonymous> (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:3513)
at t (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:217)
at Object.<anonymous> (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:3381)
at t (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:217)
at Object.e.exports (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:2992)
at t (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:217)
at Object.<anonymous> (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:1615)
at t (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:217)
at Object.<anonymous> (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:779)
at t (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:217)
at Zone.current.fork.name (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:310)
at Object.<anonymous> (D:\Dot.NetCore_Angular2_App\ProfileManagement\ClientApp\dist\main-server.js:1:315)
Current directory is: D:\Dot.NetCore_Angular2_App\ProfileManagement	

Steps to recreate

https://github.com/abrarjahin/Dot.NetCore_Angular2_App/commits/master

Current behavior

Explain what it's doing and why it's wrong

Expected behavior

Should run and should not give error window is not defined

AbrarJahin avatar Jan 04 '17 10:01 AbrarJahin

If you need to use libraries that depend on browser APIs, then you won't be able to use server-side prerendering, or at least you need to ensure that those code paths don't get hit when the app is running on the server (e.g., like in this answer: https://github.com/ligershark/CoreTemplatePack/issues/23)

SteveSandersonMS avatar Jan 10 '17 11:01 SteveSandersonMS