Not working with scaffold app created with vuejs CLI
unreturnable opened this issue · comments
So I have a scaffold app that I created using the vuejs CLI. When using the plugin I get this error:
main.js?1c90:8 Uncaught TypeError: PouchDB.plugin is not a function
I have installed the node modules as required and assumed that the setup code given in the readme needs to be placed within main.js (new to vuejs so not sure if this is correct). My main.js file looks like this:
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
const PouchDB = require('pouchdb-browser')
PouchDB.plugin(require('pouchdb-find'))
PouchDB.plugin(require('pouchdb-live-find'))
Vue.use(require('vue-pouch'), {
pouch: PouchDB,
defaultDB: 'config'
})
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App }
})
The code looks like it should work. Which vue cli command did you use to create the project? i'll see if i can reproduce it
vue init webpack my-project
and then said Yes to all the options. Was just experimenting with the framework so pretty much followed https://vuejs.org/v2/guide/installation.html
was able to reproduce. if you replace const PouchDB = require('pouchdb-browser')
with import PouchDB from 'pouchdb-browser
it should work. going to update the docs.