vue-quill-editor: Can't find variable: Quill when registering Quill modules
BUG REPORT TEMPLATE
Vue.js version and component version
Nuxt 1.3.0, Vue 2.5.13
Reproduction Link
n/a (issue has to do with Quill module usage in Nuxt)
Steps to reproduce
- In Nuxt, add a module during the configuration of the vue-quill-editor plugin (plugins/vue-quill-editor.js):
/* Client-side Quill Editor plugin */
import Vue from 'vue'
import Quill from 'quill'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
// Add Markdown Shortcuts plugin: this allows the use of
// e.g., # Heading 1, **bold** etc., to trigger style changes.
// This is the module I managed to solve by forking the original, removing all Webpack-related stuff, and importing the classes directly: https://github.com/aral/quill-markdown-shortcuts-for-vue-quill-editor
import MarkdownShortcuts from 'quill-markdown-shortcuts-for-vue-quill-editor'
Quill.register('modules/markdownShortcuts', MarkdownShortcuts)
// This is the module I encountered the same problem on:
import Emoji from 'quill-emoji/dist/quill-emoji.js'
Quill.register('modules/emoji', Emoji)
Vue.use(VueQuillEditor)
In my Nuxt config, I have it set up so that Nuxt does not apply SSR:
plugins: [
'~plugins/buefy',
{ src: '~plugins/vue-quill-editor', ssr: false }
],
What is Expected?
It should work.
What is actually happening?
Error: Can’t find variable: Quill.
I’ve documented how I managed to solve this for one module here: https://github.com/aral/quill-markdown-shortcuts-for-vue-quill-editor
However, I’ve just encountered the same issue on another component so I think there’s something inherently problematic with trying to use modules with Nuxt.
PS. If, instead of importing the script from the dist folder, I do import Emoji from 'quill-emoji', I get:
These dependencies were not found:
* aws-sdk in ./node_modules/fsevents/node_modules/node-pre-gyp/lib/unpublish.js, ./node_modules/fsevents/node_modules/node-pre-gyp/lib/publish.js and 1 other
* child_process in ./node_modules/fsevents/node_modules/detect-libc/lib/detect-libc.js, ./node_modules/fsevents/node_modules/node-pre-gyp/lib/testbinary.js and 9 others
* fs in ./node_modules/cacache/get.js, ./node_modules/chownr/chownr.js and 54 others
* module in (webpack)/lib/node/NodeTargetPlugin.js
* net in ./node_modules/forever-agent/index.js, ./node_modules/fsevents/node_modules/forever-agent/index.js and 4 others
* tls in ./node_modules/forever-agent/index.js, ./node_modules/fsevents/node_modules/forever-agent/index.js and 2 others
To install them, you can run: npm install --save aws-sdk child_process fs module net tls
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 20 (5 by maintainers)
The solution for installing plugins like quill-image-resize-module in a Nuxt/SSR app:
Okay so I was able to solve this problem for SPA apps by doing this:
You will have to make a new file called vue.config.js
Paste this code in there:
What this does is it helps Vue import quill and help register the Image resize module
and in the options for quill, make the modules true as such:
and voila! The image resize and drop should work.
@aral Thank you for the snippet, You saved me from hours of frustration! I had to make the following modifications for it to work (for me)
1: in the plugin file
2: in nuxt.config.js
Thank you!
(Ah, and quill-image-drop-module doesn’t use Webpack.)
This solution solved my problem! In nuxt.config.js
import webpack from 'webpack' export default { // Global page headers (https://go.nuxtjs.dev/config-head)// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins) plugins: [ { src: '~plugins/nuxt-quill-plugin', ssr: false } ],build: { plugins: [ new webpack.ProvidePlugin({ 'window.Quill': 'quill/dist/quill.js', 'Quill': 'quill/dist/quill.js' }) ]In plugins > nuxt-quill-plugin.js
`import Vue from ‘vue’ import VueQuillEditor, { Quill } from ‘vue-quill-editor’ import ImageResize from ‘quill-image-resize-module’
import ‘quill/dist/quill.core.css’ import ‘quill/dist/quill.snow.css’ import ‘quill/dist/quill.bubble.css’
Quill.register(‘modules/imageResize’, ImageResize) Vue.use(VueQuillEditor) `
Hi. Nice work on this!
For a non SSR app (using Vue CLI 3) I am also having this same issue: “Quill is not loaded in this application” when I try to import modules.
Have I done something wrong here?