react-draft-wysiwyg
react-draft-wysiwyg copied to clipboard
Global is not defined error after install
I just installed it following the Docs but i keep getting this error..
setImmediate.js:13 Uncaught ReferenceError: global is not defined at node_modules/fbjs/lib/setImmediate.js (setImmediate.js:13:18) at __require (chunk-J43GMYXM.js?v=56e10efa:11:50) at node_modules/draft-js/lib/editOnBeforeInput.js (editOnBeforeInput.js:27:20) at __require (chunk-J43GMYXM.js?v=56e10efa:11:50) at node_modules/draft-js/lib/DraftEditorEditHandler.js (DraftEditorEditHandler.js:15:21) at __require (chunk-J43GMYXM.js?v=56e10efa:11:50) at node_modules/draft-js/lib/DraftEditor.react.js (DraftEditor.react.js:36:30) at __require (chunk-J43GMYXM.js?v=56e10efa:11:50) at node_modules/draft-js/lib/Draft.js (Draft.js:28:19) at __require (chunk-J43GMYXM.js?v=56e10efa:11:50)
Add this on your index.html:
Add this on your index.html:
100% working
thanks a lot! another method is to fix the config file: import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react';
// https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], define: { global: 'window', }, build: { rollupOptions: { external: ['graphql'], }, }, });
@HannahNguyen6729
just wanted to share we've been following this approach for quite the sometime and certain packages causes build conflicts when we do so, based on our recent findings the recommended approach would be to (follow the 1st approach mentioned in the below so)
https://stackoverflow.com/questions/72114775/vite-global-is-not-defined
And also
The Vite docs warn against using define for global, as it can replaces the string global everywhere in the code, not just when it's used as a variable name. So @Yairopro's answer is the way to go. – Ethan Feb 21 at 3:21
@MarcoRettoreDev I cant find any index.html file in the library?
Is your project a react app ?
On Tue, 5 Dec 2023 at 17:58, Awalle Mohamed @.***> wrote:
@MarcoRettoreDev https://github.com/MarcoRettoreDev I cant find any index.html file in the library?
— Reply to this email directly, view it on GitHub https://github.com/jpuri/react-draft-wysiwyg/issues/1317#issuecomment-1840962811, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJCW74J3SDI4KTJKCYFJYZDYH4ZA5AVCNFSM6AAAAAASIYG6HWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBQHE3DEOBRGE . You are receiving this because you authored the thread.Message ID: @.***>
@MarcoRettoreDev I cant find any index.html file in the library?
There is always an index.html, in my case it was the index.blade.php because i used it on a Laravel app. You can always search index.html on your project folder to find where is it.