[Bug Report] navigator is not defined
See original GitHub issueWhen 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:
- Created 2 years ago
- Comments:12 (6 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
@YunYouJun https://github.com/vitejs/vite/discussions/1791#discussioncomment-320938
Okay, I see.