So I have an Angular Universal project working fine. After adding quite a lot of code and some external npm libraries such as Quill I am finding now a window Reference error. I have checked all my components and in all of them when I reference window it is wrapped under the if(isPlatformBrowser(this.platformId)){
.
Error message:
D:\PROYECTO SOCIAL\FRONT\dist\front\server\main.js:1
!function(e,a){for(var i in a)e[i]=a[i]}(exports,function(modules){var installedModules={},installedChunks={1:0};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}return __webpack_require__.e=function requireEnsure(chunkId){if(0!==installedChunks[chunkId]){var chunk=require("./"+({0:"components-socs-society-page-society-page-module"}[chunkId]||chunkId)+".js"),moreModules=chunk.modules,chunkIds=chunk.ids;for(var moduleId in moreModules)modules[moduleId]=moreModules[moduleId];for(var i=0;i<chunkIds.length;i++)installedChunks[chunkIds[i]]=0}return Promise.all([])},__webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||
ReferenceError: window is not defined
at Object.ah1v (D:\PROYECTO SOCIAL\FRONT\dist\front\server\main.js:1:991591)
at __webpack_require__ (D:\PROYECTO SOCIAL\FRONT\dist\front\server\main.js:1:317)
at Module.uj+Y (D:\PROYECTO SOCIAL\FRONT\dist\front\server\main.js:1:3975408)
at __webpack_require__ (D:\PROYECTO SOCIAL\FRONT\dist\front\server\main.js:1:317)
at Object.0 (D:\PROYECTO SOCIAL\FRONT\dist\front\server\main.js:1:6384)
at __webpack_require__ (D:\PROYECTO SOCIAL\FRONT\dist\front\server\main.js:1:317)
at +iJU (D:\PROYECTO SOCIAL\FRONT\dist\front\server\main.js:1:2122)
at Object.<anonymous> (D:\PROYECTO SOCIAL\FRONT\dist\front\server\main.js:1:2167)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] serve:ssr: `node dist/front/server/main.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] serve:ssr script.
Is there anyway I could check where this error is located at to determine which library or code file is causing it?
So FYI for those inexperienced with this it seems that the core problem was related to ngx Quill and adding external modules to it such as BlotFormatter or the emoji module. Here is a discussion regarding this.
Also, as @David mentioned you can get more context of the error by accessing
main.js
file withindist/yourappname/server/main.js
. If you are using VS Code you can easily jump into the faulty line of code by usingCtrl + G
and writing the line of code shown in the error message.