kaoz70 / grapesjs-blocks-bootstrap4

GrapesJS Bootstrap v4 Blocks Plugin
BSD 3-Clause "New" or "Revised" License
153 stars 106 forks source link

Uncaught ReferenceError: grapesjs is not defined #41

Closed jcsofts closed 4 years ago

jcsofts commented 4 years ago

get this error when I use it with webpack

` import GrapesJS from 'grapesjs'; import pluginBootstrap4 from 'grapesjs-blocks-bootstrap4 GrapesJS.init({ ... plugins: [ pluginBootstrap4], ... })

`

and got below error when run it grapesjs-blocks-bootstrap4.min.js:11 Uncaught ReferenceError: grapesjs is not defined

image

kaoz70 commented 4 years ago

As per the documentation, you have to install grapesjs as a peer dependency:

npm i grapesjs --no-save

Did you do that?

jcsofts commented 4 years ago

yeah, I do that.

I download the source to my project and remove comment out the first line of grapesjs-blocks-bootstrap4/src/index.js change //import grapesjs from 'grapesjs'; to import grapesjs from 'grapesjs'; then it works

kaoz70 commented 4 years ago

Do you have any steps to repro this? It would be good to know also what versions of: OS, Node, NPM, Yarn, browser, etc.

sircoko commented 4 years ago

Hi! I have a similar issue. In this case I'm working with a major grapesjs project, so I really dont want to take this plugin as a standalone but import this plugin into the main project.
So, I have cloned the original GrapesJS repo, then did npm i grapesjs-blocks-bootstrap4 and tried to do import pluginBootstrap4 from 'grapesjs-blocks-bootstrap4' but it says that cannot find grapesjs.

I uncommented the import grapesjs line, and also re-installed the grapesjs via npm i grapesjs --no-save (which doesnt have too much sense for me as I'm already working inside grapejs) ...

Please, I'm really lost

kaoz70 commented 4 years ago

Ok, I see what you mean @jcsofts @sircoko , I've updated the plugin to 0.2.3, can you see if this fixes the issue.

sircoko commented 4 years ago

Ok I checked, reinstalled the node_modules and package lock.

image

It could be me doing something wrong..
@kaoz70 would you tell me about the steps I should follow in order to embed this plugin into a grapesjs project? Just to be suer. Thanks

kaoz70 commented 4 years ago

@sircoko please check this link out for a simple implementation: https://codesandbox.io/s/sad-villani-w2w8l?file=/src/index.js

jcsofts commented 4 years ago

@kaoz70 thanks, the bug fixed

kaoz70 commented 4 years ago

Great! Then I'm closing this issue.