vue-strap is a vuecomponent , and i want to use it like this:
require('vue-strap').alert
but it report errors below:
Module build failed: TypeError: this._init is not a function
at Object.Vue (E:\vue\vue-strap1\node_modules\vue-strap\node_modules\vue\src
\vue.js:19:8)
the code in the vue-strap/src/main.js file:
var _AlertVue = require('./Alert.vue');
exports.alert = _AlertVue;
I'm seeing the same thing with custom components.
@bradstewart Are you exporting a constructor created by Vue.extend() instead of a plain object? If that's the case it should now work in 4.0.10.
@yyx990803 So I can't quite figure out why the error printed to the console was from require('component.vue'), the call stack led me back to Vue.use(VueRouter) which was the actual problem. After updatingvue-router and vue-loader, everything looks good. (I am only exporting plain objects though).
FWIW, the error referenced in this issue's title is what I was getting simply because I hadn't run npm install --save vue-loader (and then I had to first manually install all of the peer dependencies, since I am using npm v3, and then retry npm install --save vue-loader and then it installed successfully and then my webpack bundle built successfully without the error).
It might be worth adding a reminder about actually installing the loader to the README.md, for slow folks like me... :grin:
@davidrunger was my issue/resolution also. Thanks!
For anyone else that needs the list of the peer dependencies:
vue-loader
vue-html-loader
css-loader
style-loader
babel-loader
babel-core
babel-plugin-transform-runtime
babel-preset-es2015
babel-runtime
vue-hot-reload-api
Or copy/paste version for your convenience:
npm install --save vue vue-loader vue-html-loader css-loader style-loader babel-loader babel-core babel-plugin-transform-runtime babel-preset-es2015 babel-runtime vue-hot-reload-api
(Without --save)
npm install vue vue-loader vue-html-loader css-loader style-loader babel-loader babel-core babel-plugin-transform-runtime babel-preset-es2015 babel-runtime vue-hot-reload-api
Removing node_modules and installing it again helped.
Most helpful comment
FWIW, the error referenced in this issue's title is what I was getting simply because I hadn't run
npm install --save vue-loader(and then I had to first manually install all of the peer dependencies, since I am using npm v3, and then retrynpm install --save vue-loaderand then it installed successfully and then my webpack bundle built successfully without the error).It might be worth adding a reminder about actually installing the loader to the README.md, for slow folks like me... :grin: