Failed to deploy: Reference error self is not defined
See original GitHub issueš Bug Report
I get a ReferenceError in Webpack while running yarn build to deploy the Hermes website.
I think itās due to monaco-editor-webpack-plugin but Iām not sure.
Have you read the Contributing Guidelines on issues?
Yes
To Reproduce
Note: I setup a branch that has the required hermes.js files weāre only adding to the gh-pages branch during deploys.
- Clone my branch here: https://github.com/rickhanlonii/hermes/tree/rh-deploy-hermes
- cd website
- yarn build
- Observe error
Expected behavior
- Build completes, site deploys
Actual Behavior
 
Your Environment
- Docusaurus version used: 2.0.0-alpha.43
- Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Node 12.9.1
- Operating system and version (desktop or mobile): macOS
Reproducible Demo
https://github.com/rickhanlonii/hermes/tree/rh-deploy-hermes
Issue Analytics
- State:
- Created 3 years ago
- Comments:24 (6 by maintainers)
 Top Results From Across the Web
Top Results From Across the Web
reactjs - Why am I getting ReferenceError: self is not defined ...
The error occurs because the library requires Web APIs to work, which are not available when Next.js pre-renders the page on the server-sideĀ ......
Read more >middlewares - ReferenceError: self is not defined Ā· Issue #38149
I'm experiencing the same issue. Upgraded to Next.js v12.2 and migrated the middleware accordingly. But builds are breaking with the exact sameĀ ...
Read more >ReferenceError: self is not defined - Blockcerts Forum
This means that there is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it...
Read more >node-self - npm
Even with undeclared identifiers, it will return 'undefined' instead of throwing an error. undeclared; // ReferenceError: undeclared is not ...
Read more >self is not defined nextjs | The AI Search Engine You Control
Why am I getting ReferenceError: self is not defined when I import a client-side library? ... The error occurs because the library requires...
Read more > Top Related Medium Post
Top Related Medium Post
No results found
 Top Related StackOverflow Question
Top Related StackOverflow Question
No results found
 Troubleshoot Live Code
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
Top Related Reddit Thread
No results found
 Top Related Hackernoon Post
Top Related Hackernoon Post
No results found
 Top Related Tweet
Top Related Tweet
No results found
 Top Related Dev.to Post
Top Related Dev.to Post
No results found
 Top Related Hashnode Post
Top Related Hashnode Post
No results found

I have a similar issue when importing the Redoc React Component (https://github.com/Redocly/redoc#usage-as-a-react-component). The error only occurs when Iām actually importing the component.
My workaround was
That said, is there any way to bypass or disable the SSR bundle? That may not be the right way to ask that question, but I just want a client bundle that I can deploy.
@mharsat Itās usually happen because of SSR related issues. You can bypass that by loading those only for client side.
I did something like that: https://github.com/dotansimha/graphql-code-generator/blob/master/website/src/components/live-demo/Editor.js#L1-L4