react-draft-wysiwyg icon indicating copy to clipboard operation
react-draft-wysiwyg copied to clipboard

Global is not defined error after install

Open etekumoses opened this issue 2 years ago • 7 comments

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)

etekumoses avatar Nov 23 '22 09:11 etekumoses

Add this on your index.html:

MarcoRettoreDev avatar Dec 05 '22 15:12 MarcoRettoreDev

Add this on your index.html:

100% working

ritik373 avatar Feb 11 '23 18:02 ritik373

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 avatar Jul 26 '23 15:07 HannahNguyen6729

@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

iamshz97 avatar Sep 28 '23 08:09 iamshz97

@MarcoRettoreDev I cant find any index.html file in the library?

awallemo avatar Dec 05 '23 14:12 awallemo

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: @.***>

etekumoses avatar Dec 05 '23 15:12 etekumoses

@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.

MarcoRettoreDev avatar Dec 05 '23 16:12 MarcoRettoreDev