question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

window is not defined error with AOT

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior My goal is to set up AOT compilation in my Angular 4 application, which includes ngx-datatable. I am using the template from https://github.com/damienbod/AngularWebpackVisualStudio. “npm run webpack-production” gives me the following error:

ERROR in E:/MyApp/Sources/Web/node_modules/@swimlane/ngx-datatable/release/components/datatable.component.css:219 return window && document && document.all && !window.atob; ^ ReferenceError: window is not defined at E:/MyApp/Sources/Web/node_modules/@swimlane/ngx-datatable/release/components/datatable.component.css:219:9 at E:/MyApp/Sources/Web/node_modules/@swimlane/ngx-datatable/release/components/datatable.component.css:208:46 at module.exports (E:/MyApp/Sources/Web/node_modules/@swimlane/ngx-datatable/release/components/datatable.component.css:263:46) at Object.<anonymous> (E:/MyApp/Sources/Web/node_modules/@swimlane/ngx-datatable/release/components/datatable.component.css:81:36) at webpack_require (E:/MyApp/Sources/Web/node_modules/@swimlane/ngx-datatable/release/components/datatable.component.css:20:30) at E:/MyApp/Sources/Web/node_modules/@swimlane/ngx-datatable/release/components/datatable.component.css:63:18 at E:/MyApp/Sources/Web/node_modules/@swimlane/ngx-datatable/release/components/datatable.component.css:66:10 at ContextifyScript.Script.runInContext (vm.js:53:29) at WebpackResourceLoader._evaluate (E:\MyApp\Sources\Web\node_modules@ngtools\webpack\src\resource_loader.js:84:34) at _compile.then (E:\MyApp\Sources\Web\node_modules@ngtools\webpack\src\resource_loader.js:96:36)

Expected behavior No error

Reproduction of the problem Clone https://github.com/damienbod/AngularWebpackVisualStudio, add ngx-datatable to it, run “npm run webpack-production”

What is the motivation / use case for changing the behavior?

Please tell us about your environment: “dependencies”: { “@angular/common”: “4.4.4”, “@angular/compiler”: “4.4.4”, “@angular/core”: “4.4.4”, “@angular/forms”: “4.4.4”, “@angular/http”: “4.4.4”, “@angular/platform-browser”: “4.4.4”, “@angular/platform-browser-dynamic”: “4.4.4”, “@angular/router”: “4.4.4”, “@swimlane/ngx-datatable”: “10.2.3”, “systemjs”: “0.20.19”, “types”: “0.1.1”, “zone.js”: “0.8.18” }, “devDependencies”: { “@ngtools/webpack”: “^1.7.1”, “@types/node”: “^8.0.28”, “@types/jasmine”: “^2.6.0”, “angular-router-loader”: “^0.6.0”, “angular2-template-loader”: “^0.6.2”, “awesome-typescript-loader”: “^3.2.2”, “clean-webpack-plugin”: “^0.1.16”, “codelyzer”: “^3.1.2”, “concurrently”: “^3.5.0”, “copy-webpack-plugin”: “4.1.0”, “css-loader”: “^0.28.4”, “file-loader”: “1.1.5”, “html-webpack-plugin”: “^2.30.1”, “jasmine-core”: “^2.7.0”, “jquery”: “^3.2.1”, “json-loader”: “^0.5.7”, “karma”: “^1.7.0”, “karma-chrome-launcher”: “^2.2.0”, “karma-jasmine”: “^1.1.0”, “karma-sourcemap-loader”: “^0.3.7”, “karma-spec-reporter”: “^0.0.31”, “karma-webpack”: “^2.0.4”, “node-sass”: “^4.5.3”, “raw-loader”: “^0.5.1”, “rimraf”: “^2.6.1”, “sass-loader”: “^6.0.6”, “source-map-loader”: “0.2.2”, “style-loader”: “0.19.0”, “tslint”: “^5.6.0”, “tslint-loader”: “^3.5.3”, “typescript”: “2.3.4”, “url-loader”: “0.6.2”, “webpack”: “^3.6.0”, “webpack-dev-server”: “2.9.1” },

  • Table version: 10.2.3

  • Angular version: 4.4.3

  • Browser: all

  • Language: TypeScript 2.3.4

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
kcsahoocommented, Nov 8, 2017

Same error with Angular 5 and V11.0.0 while AOT compilation Excluding node_modules also does not help

0reactions
SaiKrishnaTej23commented, Apr 29, 2018

I am facing the same issue … I am currently using Angular 4.3.0 along with ngx-datatable 10.2.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error on chorme extension: Uncaught ReferenceError: window ...
The issue is that when I upload the extension it shows a error message saying: Uncaught ReferenceError: window is not defined.
Read more >
How to solve "window is not defined" errors in React and Next.js
First solution: typeof​​ Because typeof won't try to evaluate "window", it will only try to get its type, in our case in Node....
Read more >
[SOLVED] Error: ReferenceError: window is not defined
I have issue with Error: ReferenceError: window is not defined as follows When I do yarn build and with typescript it not have...
Read more >
Error with webpack (window not defined) · Issue #405 - GitHub
Hi, i use the new webpack for nativescript version 0.9.1 and when compile i got this error. when i don't use the webpack...
Read more >
How to fix errors like ReferenceError Window is Not Defined in ...
We can fix the above issue by adding a check on the document variable and rendering a fallback UI. // file: Question.js import...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found