Vue-loader: Module build failed: TypeError: this._init is not a function

Created on 14 Oct 2015  路  7Comments  路  Source: vuejs/vue-loader

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;

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 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:

All 7 comments

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.

409 is helped

Was this page helpful?
0 / 5 - 0 ratings

Related issues

githoniel picture githoniel  路  3Comments

fuyan-run picture fuyan-run  路  3Comments

birdgg picture birdgg  路  3Comments

lijialiang picture lijialiang  路  3Comments

NextSeason picture NextSeason  路  3Comments