Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module build failed: TypeError: this._init is not a function #23

Closed
johnwonder opened this issue Oct 14, 2015 · 7 comments
Closed

Module build failed: TypeError: this._init is not a function #23

johnwonder opened this issue Oct 14, 2015 · 7 comments

Comments

@johnwonder
Copy link

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;

@bradstewart
Copy link

I'm seeing the same thing with custom components.

@yyx990803
Copy link
Member

@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.

@bradstewart
Copy link

@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).

@davidrunger
Copy link

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... 😁

@tilleps
Copy link

tilleps commented Nov 10, 2015

@davidrunger was my issue/resolution also. Thanks!

For anyone else that needs the list of the peer dependencies:

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

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

@karol-f
Copy link

karol-f commented Oct 5, 2016

Removing node_modules and installing it again helped.

@felixzhooou
Copy link

#409 is helped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants