Skip to content

Window is not defined #1233

@ruizmarc

Description

@ruizmarc

Environment details

  1. Not related with any API version
  2. SO is not the source of the problem
  3. js-api-loader: 2.1.0

Steps to reproduce

  1. Try to compile your code in an environment without Window available. For example, Angular Prerenderer which uses SSR.

Code example

import { importLibrary, setOptions } from '@googlemaps/js-api-loader';

Stack trace

 ReferenceError: window is not defined
     at <anonymous> (/ptp/app/.angular/prerender-root/30cdec35-f241-46db-97d1-970d84579af6/node_modules/@googlemaps/js-api-loader/dist/index.js:25:22)
     at ModuleJob.run (node:internal/modules/esm/module_job:439:25)
     at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
     at async node:internal/modules/esm/loader:633:26
     at async extractRoutes (/ptp/app/node_modules/@angular/build/src/utils/server-rendering/routes-extractor-worker.ts:40:5)
     at async onMessage (/ptp/app/node_modules/piscina/src/worker.ts:184:18)

Following these steps will guarantee the quickest resolution possible.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions