-
Notifications
You must be signed in to change notification settings - Fork 44
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
Error "Cannot read property 'use' of undefined" #50
Comments
Hi, Can you tell me more about your build tools? Are you using webpack? If so, could you please post your Cheers! |
Am having the same error, kindly assist |
I'ld be glad to help, but there's just not enough information
|
"vue": "^2.5.7", |
|
@GerkinDev
This is my const path = require('path');
const webpack = require('webpack');
const { VueLoaderPlugin } = require('vue-loader');
const resolve = relativePath => path.resolve(__dirname, '..', relativePath);
module.exports = {
mode: 'development',
entry: {
vue: 'vue',
index: resolve('src/main.js'),
},
output: {
filename: 'bundle.min.js',
path: resolve('dist'),
},
module: {
rules: [
{
test: /.(ttf|woff2|woff|eot|jpg|jpeg|png|svg)$/,
use: ['file-loader'],
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
css: ['vue-style-loader', {
loader: 'css-loader',
}],
'scss': 'vue-style-loader!css-loader!sass-loader',
'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax',
js: [
'babel-loader',
],
},
cacheBusting: true,
},
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [
resolve('src'),
resolve('node_modules/webpack-dev-server/client'),
],
},
{
test: /\.scss$/,
use: [
{
loader: 'css-loader'
},
{
loader: 'sass-loader'
}
]
},
{
test: /\.css$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}]
}
],
},
devtool: 'eval',
plugins: [
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new VueLoaderPlugin(),
new webpack.ProvidePlugin({
$: 'jquery',
jquery: 'jquery',
'window.jQuery': 'jquery',
jQuery: 'jquery'
})
],
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
},
extensions: ['*', '.vue', '.js', '.json'],
},
performance: {
hints: false,
},
}; |
tl;drAdd this to your module.exports = {
resolve: {
alias: {
'vuejs-datatable': 'vuejs-datatable/dist/vuejs-datatable.esm.js',
}
},
} Long explanationPretty much like Vue itself for its full build (see vuejs doc), vuejs-datatable is shipped in 2 different builds (with the PR #47 & v1.7.0): an IIFE and an ESM build. The main difference between those builds is that the IIFE rely on globally exposed variables ( But it is still quite odd that adding @pstephan1187 maybe we should replace the index file in the |
Hey there, any news on this? Is the problem solved? |
Hi! I couldn't reply earlier. I try it today and it works! |
@GerkinDev I'll get that change made and pushed up. Thank you |
Spent hours to find out the reason of the same error. With vue cli 3, webpack 4.26.0 and vuejs-datatable 1.7.0, I've also fixed the "browser" field to "dist/vuejs-datatable.esm.js". |
Hi, I am having similar issue. I have Vue 3.1.3 installed with webpack. Everything is working ok before adding DataTable, My Main.js is given below, please guide what to do? import 'bootstrap/dist/css/bootstrap.min.css' Vue.use(VueResource); //Vue.http.headers.common['Access-Control-Allow-Origin'] = 'true'; Vue.config.productionTip = false; window.Vue = Vue; new Vue({ ===================================== [HMR] Waiting for update signal from WDS... log.js:24:4 |
Hi @usmankah Can you please post your stack trace with files? Thank you |
|
Above solution works for me |
You can do it in a simple way without mod webpack: import DatatableFactory from 'vuejs-datatable/dist/vuejs-datatable.esm.js'; That's all you need)) |
Thank you !! |
Still have this issue with my setup. We are using Vue CLI 3 (so, no webpack.config. it is vue.config.js hence cannot do the above suggested work around), Typescript - so cannot do the import DatatableFactory from ../vuejs.datatable.esm.js file either. Please advise. Thanks! |
@shivanaru As described in vuejs/vue-cli#2398, you can still alias modules in the |
Yes! that worked. Thank you very much!! Below was my setting, leaving it here, just in case someone else needs it. in vue.config.js module.exports = { |
@SerGioPicconti Thanks a lot! |
** > How can i Solve this issue** |
I'm importing and using as per docs:
And i'm getting the following error:
I tried `window.Vue = Vue;' with no luck, thinking that it was related to #28
What could it be?
The text was updated successfully, but these errors were encountered: