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.

"TypeError: Cannot read property 'on' of undefined"

See original GitHub issue

I made a very simple project where I wanted to test vue-konva I get the following:

Error in mounted hook: "TypeError: Cannot read property 'on' of undefined"

My component has a very simple template:

<template>
    <v-stage :config="configKonva">
        <v-layer>
            <v-circle :config="configCircle"></v-circle>
        </v-layer>
    </v-stage>
</template>

and data:

   data () {
      return {
        configKonva: {
          width: 200,
          height: 200,
        },
        configCircle: {
          x: 100,
          y: 100,
          radius: 70,
          fill: 'red',
          stroke: 'black',
          strokeWidth: 4,
        },
        icons: {},
      }
    },

the google chrome trace looks like that:

TypeError: Cannot read property 'on' of undefined
    at VueComponent.mounted (admin.js:84063)
    at callHook (admin.js:90305)
    at Object.insert (admin.js:91542)
    at invokeInsertHook (admin.js:93344)
    at Vue.patch [as __patch__] (admin.js:93563)
    at Vue._update (admin.js:90044)
    at Vue.updateComponent (admin.js:90172)
    at Watcher.get (admin.js:90526)
    at new Watcher (admin.js:90515)
    at mountComponent (admin.js:90179)

admin being the name of my app.

Any idea where does the problem comes from? It looks almost as some vue-konva components would not be correctly registered, but it that case, I would get a different error message from Vue.

I imported vue-konva with import and Vue.use(VueKonva)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

17reactions
jon-htcommented, Nov 10, 2018

Hi,

I have an ElectronJS project and I also ran into this bug. To make it work, I had to add vue-konva to my whiteListedModules in webpack config file (webpack.renderer.config.js)

/**
 * List of node_modules to include in webpack bundle
 *
 * Required for specific packages like Vue UI libraries
 * that provide pure *.vue files that need compiling
 * https://simulatedgreg.gitbooks.io/electron-vue/content/en/webpack-configurations.html#white-listing-externals
 */
let whiteListedModules = ['vue', 'vuetify', 'vue-konva'];

let rendererConfig = {
  devtool: '#cheap-module-eval-source-map',
  entry: {
    renderer: path.join(__dirname, '../src/renderer/main.js')
  },
  externals: [
    ...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d))
  ],
  ...
}

I hope it can help you too

1reaction
lvbiruicommented, Sep 24, 2019

i have the same problem like jon-ht ,but it dose not work…@jon-ht

@jon-ht 's solution is worked, i put the ‘vue-konva’ and restart my project (close the vscode and restart),and it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
[SOLVED] Cannot Read Property of Undefined in JavaScript
The “cannot read property of undefined” error occurs when you attempt to access a property or method of a variable that is undefined...
Read more >
Uncaught TypeError: Cannot read property of undefined In
JavaScript TypeError is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or...
Read more >
Node.js Cannot read property 'on' of undefined - Stack Overflow
TypeError : Cannot read property 'on' of undefined at Object.<anonymous> (E:\Project\node\BasicSocial\server.js:12:2) ...
Read more >
How to Avoid the Infamous "Cannot read properties of ... - Bitovi
Interpreting undefined or null as subtypes of all other types can lead to runtime problems. For example, if you try to get the...
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