ReferenceError: window is not defined
See original GitHub issueHello.
I would like to use this module with angular universal. However, the following error occurred.
> node dist/server.js
/Users/cse_t_kutsuna/git/study/blah-map/node_modules/leaflet/dist/leaflet-src.js:226
var requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer;
^
ReferenceError: window is not defined
at /Users/me/git/study/blah-map/node_modules/leaflet/dist/leaflet-src.js:226:86
at version (/Users/me/git/study/blah-map/node_modules/leaflet/dist/leaflet-src.js:6:65)
at Object.<anonymous> (/Users/me/git/study/blah-map/node_modules/leaflet/dist/leaflet-src.js:9:2)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! blah-map@0.0.0 start: `node dist/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the blah-map@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/me/.npm/_logs/2017-07-25T06_32_11_130Z-debug.log
I tried using isPlatformBrowser with client only but leafletOptions parse error appears
Is there any good solution?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
How to solve "window is not defined" errors in React and Next.js
How to solve "window is not defined" errors in React and Next.js · 1. First solution: typeof · 2. Second solution: the useEffect...
Read more >How to solve Next.js window is not defined
ReferenceError: window is not defined is a pretty common error you may run into when using Next.js for the first time but don't...
Read more >referenceerror: window is not defined, how to solve
Here's how to fix the “referenceerror: window is not defined” error that you might have in Node.js or with a tool like Next.js....
Read more >How To Solve ReferenceError window is not defined in ...
Fixing a window is not defined error can be quite simple. In most cases, all you will need to do is wrap your...
Read more >[Solved] ReferenceError : window is not defined - ItsJavaScript
The ReferenceError : window is not defined error mainly occurs if you are using the window object in Node.js, React.js, Next.js.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m gonna close this for now as I don’t think there’s an action here. Thanks for using the plugin!
closed? what was the cause? when I run npm run build:ssr && npm run serve:ssr I am getting the same error! window not defined?? but everything works fine on my local server ng serve port (4200)? When will angular make ssr or pre rendering a little more user friendly?
my angular.json { “$schema”: “./node_modules/@angular/cli/lib/config/schema.json”, “version”: 1, “newProjectRoot”: “projects”, “projects”: { “my-app”: { “root”: “”, “sourceRoot”: “src”, “projectType”: “application”, “prefix”: “app”, “schematics”: { “@schematics/angular:component”: { “styleext”: “scss” } }, “architect”: { “build”: { “builder”: “@angular-devkit/build-angular:browser”, “options”: { “outputPath”: “dist/browser”, “index”: “src/index.html”, “main”: “src/main.ts”, “polyfills”: “src/polyfills.ts”, “tsConfig”: “src/tsconfig.app.json”, “assets”: [“src/favicon.ico”, “src/assets”, “src/manifest.json”], “styles”: [ { “input”: “node_modules/@angular/material/prebuilt-themes/indigo-pink.css” }, “node_modules/angular-bootstrap-md/scss/bootstrap/bootstrap.scss”, “node_modules/angular-bootstrap-md/scss/mdb-free.scss”, “src/styles.scss” ], “scripts”: [“node_modules/chart.js/dist/Chart.js”] }, “configurations”: { “production”: { “fileReplacements”: [ { “replace”: “src/environments/environment.ts”, “with”: “src/environments/environment.prod.ts” } ], “optimization”: true, “outputHashing”: “all”, “sourceMap”: false, “extractCss”: true, “namedChunks”: false, “aot”: true, “extractLicenses”: true, “vendorChunk”: false, “buildOptimizer”: true, “serviceWorker”: true } } }, “serve”: { “builder”: “@angular-devkit/build-angular:dev-server”, “options”: { “browserTarget”: “my-app:build” }, “configurations”: { “production”: { “browserTarget”: “my-app:build:production” } } }, “extract-i18n”: { “builder”: “@angular-devkit/build-angular:extract-i18n”, “options”: { “browserTarget”: “my-app:build” } }, “test”: { “builder”: “@angular-devkit/build-angular:karma”, “options”: { “main”: “src/test.ts”, “polyfills”: “src/polyfills.ts”, “tsConfig”: “src/tsconfig.spec.json”, “karmaConfig”: “src/karma.conf.js”, “styles”: [ { “input”: “node_modules/@angular/material/prebuilt-themes/indigo-pink.css” }, “src/styles.scss” ], “scripts”: [], “assets”: [“src/favicon.ico”, “src/assets”, “src/manifest.json”] } }, “lint”: { “builder”: “@angular-devkit/build-angular:tslint”, “options”: { “tsConfig”: [“src/tsconfig.app.json”, “src/tsconfig.spec.json”], “exclude”: [“/node_modules/”] } }, “server”: { “builder”: “@angular-devkit/build-angular:server”, “options”: { “outputPath”: “dist/server”, “main”: “src/main.server.ts”, “tsConfig”: “src/tsconfig.server.json” } } } }, “my-app-e2e”: { “root”: “e2e/”, “projectType”: “application”, “architect”: { “e2e”: { “builder”: “@angular-devkit/build-angular:protractor”, “options”: { “protractorConfig”: “e2e/protractor.conf.js”, “devServerTarget”: “my-app:serve” }, “configurations”: { “production”: { “devServerTarget”: “my-app:serve:production” } } }, “lint”: { “builder”: “@angular-devkit/build-angular:tslint”, “options”: { “tsConfig”: “e2e/tsconfig.e2e.json”, “exclude”: [“/node_modules/”] } } } } }, “defaultProject”: “my-app” }