Replies: 3 comments 1 reply
-
|
got the same error, Still looking for a solution... |
Beta Was this translation helpful? Give feedback.
-
|
If you try to add something that requires a browser or window element to a server-side rendered component, the compiler may throw an error. In such cases, you can load the component using the "browserOnly" or execution environment hook. For example, to load a customElement component in the browserOnly hook and avoid the error, you can do the following: import { BrowserOnly } from "@docusaurus/core"; return ( In this code snippet, the BrowserOnly component from the @docusaurus/core package ensures that the component is only rendered in the browser, while the require statement inside the callback function dynamically loads the SlButton component from the "@shoelace-style/shoelace/dist/react" module. This way, the component can safely use browser-specific features without causing any server-side rendering errors. |
Beta Was this translation helpful? Give feedback.
-
|
🙏Thanks a lot,your suggestion inspired me. In my case, I was tring to render react-native components,I have written a webpack plugin to translate Everthing is ok when I run And then I refer to the react-native-element docusaurus document's config // ...
resolve: {
alias: {
'react-native$': 'react-native-web',
//...
},
fallback: isServer
? {}
: {
path: require.resolve('path-browserify'),
os: require.resolve('os-browserify/browser'),
fs: false,
process: 'process/browser',
},
},It works! I hope my experience will help you 😄 @nhaqi2c |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am using https://shoelace.style/ web component in docusaurus component. The Dev mode is working fine though am unable to build it for production. I am getting the following error.
[ERROR] Unable to build website for locale en.
[ERROR] Error: Failed to compile with errors.
at D:\i2c-lib-portal\node_modules@docusaurus\core\lib\webpack\utils.js:180:24
at D:\i2c-lib-portal\node_modules\webpack\lib\MultiCompiler.js:554:14
at processQueueWorker (D:\i2c-lib-portal\node_modules\webpack\lib\MultiCompiler.js:491:6)
at processTicksAndRejections (node:internal/process/task_queues:78:11)
Beta Was this translation helpful? Give feedback.
All reactions