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.

Vue 3/Vite compatibility

See original GitHub issue

Issue Description

When trying to use vue-matomo (v3.14.0-0) with Vue 3/Vite the following error occurs:

[Vue warn]: A plugin must either be a function or an object with an "install" function.

My main.js

import matomo from 'vue-matomo'
import { createApp } from 'vue'
import App from './App.vue'
import './index.css'

createApp(App)
  .use(matomo, {
    host: 'https://matomo.example.com',
    siteId: 42,
  })
  .mount('#app')

It works when importing src:

import matomo from 'vue-matomo/src'

which explains, why the example for vue3 in this repository worked.

Steps to reproduce:

$ npm init vite-app vue3-matomo-demo
$ cd vue3-matomo-demo
$ npm install --save vue-matomo

edit main.js according to the example above

$ npm install
$ npm run dev

Open http://localhost:3000 and check the console

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
AmazingDreamscommented, Oct 15, 2020

Seems like something with the type of packager used? Maybe we could export an object with install method, if that doesn’t break compatibility with other setups

2reactions
jordan-boyercommented, Oct 15, 2020

Base on this I think it’s intended since it’s only support natif ES import.

And it’s mainly because we are using a default export for the install function.

Another syntax you can use is

import matomo from 'vue-matomo'
import { createApp } from 'vue'
import App from './App.vue'
import './index.css'

createApp(App)
  .use(matomo.default, {
    host: 'https://matomo.example.com',
    siteId: 42,
  })
  .mount('#app')
Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started - Vite
Scaffolding Your First Vite Project #. Compatibility Note. Vite requires Node.js version 14.18+, 16+. However, some templates require a higher Node.js version ...
Read more >
Vite 3.0 is out!
Compatibility Notes # · Vite no longer supports Node. · Vite is now published as ESM, with a CJS proxy to the ESM...
Read more >
Plugins - Vite
Before searching for a Vite or Compatible Rollup plugin, check out the Features Guide. ... Provides Vue 3 JSX support (via dedicated Babel...
Read more >
Building for Production - Vite
Browser Compatibility​​ The production bundle assumes support for modern JavaScript. By default, Vite targets browsers which support the native ES Modules, ...
Read more >
Features | Vite
Vite provides first-class Vue support: Vue 3 SFC support via @vitejs/plugin-vue; Vue 3 JSX support via @vitejs/plugin-vue-jsx; Vue 2.7 ...
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