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.

[Bug Report] navigator is not defined

See original GitHub issue

When i build monaco-editor with vite-ssg.

I get navigator is not defined.

A recurring example: web-resume

git clone https://github.com/YunYouJun/web-resume
pnpm install
pnpm run build
ReferenceError: navigator is not defined
    at Module.<anonymous> (/Users/yunyou/github/pages/web-resume/.vite-ssg-temp/main.js:7987:19)
    at Module.o._compile (/Users/yunyou/github/pages/web-resume/node_modules/.pnpm/registry.nlark.com+jiti@1.10.1/node_modules/jiti/dist/v8cache.js:2:2778)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at __require (/Users/yunyou/github/pages/web-resume/node_modules/.pnpm/registry.nlark.com+vite-ssg@0.12.0_8be4ce4ce3ee9f8584c22c4e982f597c/node_modules/vite-ssg/dist/chunk-3FHQZVYO.js:22:12)
    at build (/Users/yunyou/github/pages/web-resume/node_modules/.pnpm/registry.nlark.com+vite-ssg@0.12.0_8be4ce4ce3ee9f8584c22c4e982f597c/node_modules/vite-ssg/dist/node/cli.js:140:52)
    at async Object.handler (/Users/yunyou/github/pages/web-resume/node_modules/.pnpm/registry.nlark.com+vite-ssg@0.12.0_8be4ce4ce3ee9f8584c22c4e982f597c/node_modules/vite-ssg/dist/node/cli.js:229:3)
error Command failed with exit code 1.

I try it, but it doesn’t work.

if (typeof navigator !== 'undefined') {
  const monaco = await import('monaco-editor')
  console.log(monaco)
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

Navigator is not defined----bug - Theia Community
navigator is a browser API. If you require code in the backend that ends up executing browser scripts you will get errors.
Read more >
Vue js ReferenceError: navigator is not defined - Stack Overflow
I'm getting the error below upon refreshing the page: ReferenceError: navigator is not defined at VueComponent.
Read more >
Getting "ReferenceError: navigator is not defined" in Next.js app
Getting error - ReferenceError: navigator is not defined error from Plasmic in development and production for our NextJS app
Read more >
Error during timezone guessing [ReferenceError: navigator is ...
Check Error Console Actual Results: Error: Skipping Operating System timezone '(null)'. ReferenceError: navigator is not defined Source File: file:///[.
Read more >
Troubleshooting | React Navigation
These issues may or may not be related to React Navigation itself. ... you should open an issue on the relevant repo's issue...
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