question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'imports' of undefined

See original GitHub issue

Using Vue.js 2.2.6 with official webpack template and Vue-Quill-Editor

Console logs in dev run:

Uncaught TypeError: Cannot read property 'imports' of undefined (image-resize.min.js?c9ce:1)

Code here:


// main.js
<script>

    import Vue from 'vue';
    // some plugins here
    import VueQuillEditor from 'vue-quill-editor';
    Vue.use(VueQuillEditor);
    
</script>

// some *.vue file
<script>

	import Quill from 'quill';
	import { ImageResize } from 'quill-image-resize-module';

	Quill.register('modules/imageResize', ImageResize);

	export default {
		name: 'editor',
		data() {
			return {
			    // some code
				Editor: {
				    // some code
					options: {
					    // some code
						modules: {
							imageResize: {
								displaySize: true
							}
						}
					}
				}
			}
		}
	}
</script>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:31
  • Comments:78

github_iconTop GitHub Comments

135reactions
jspainecommented, May 27, 2017

Managed to get v3.0 and the image-drop module working with webpack

webpack.config.js:

module: {
  rules: [
    {
      test: /\.js$/,
      exclude: /node_modules(?!\/quill-image-drop-module|quill-image-resize-module)/,
      loader: 'babel-loader',
      query: {...}
    }
  ]
}
plugins: [
  new webpack.ProvidePlugin({
    'window.Quill': 'quill'
  })
]

Component.js:

import {ImageDrop} from 'quill-image-drop-module'
import ImageResize from 'quill-image-resize-module'

Quill.register('modules/imageResize', ImageResize)
Quill.register('modules/imageDrop', ImageDrop)

const quillModules = {
  ...
  imageDrop: true,
  imageResize: {}
}

You can also import the minified file from each module instead of transforming them with babel, but the image-drop module registers itself with Quill so you have to remove that.

32reactions
ibudisteanucommented, Aug 6, 2017

@jspaine thanks a lot for assisting me!!! After 4-5 hours of pulling my hair… if found the solution:

    new webpack.ProvidePlugin({
        'window.Quill': 'quill/dist/quill.js',
        'Quill': 'quill/dist/quill.js',
    }),

I had to declare even Quill in the webpack…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'imports' of undefined · Issue #140 ...
I'm trying to include the image resizing but I keep getting Uncaught TypeError: Cannot read property 'imports' of undefined.
Read more >
Cannot read property 'imports' of undefined (react-quill ...
Since I'm using react and thus do not have a tsconfig file, I'm unable to follow solutions available on the internet. My code:...
Read more >
TypeError: Cannot read property 'imports' of undefined
I was able to compile your code and migrate. Can you share the command that you were running?
Read more >
Webpack import returns undefined, depending on the order of ...
JavaScript : Webpack import returns undefined, depending on the order of imports [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] ...
Read more >
Name may be undefined, or defined from star imports
This warning occurs in conjunction with issue F403, 'from module import *' used . It means that the variable name could be undefined,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found