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

Uncaught TypeError: Super expression must either be null or a function. #379

Closed
ghost opened this issue Jun 27, 2019 · 10 comments
Closed

Uncaught TypeError: Super expression must either be null or a function. #379

ghost opened this issue Jun 27, 2019 · 10 comments
Labels

Comments

@ghost
Copy link

ghost commented Jun 27, 2019

@NightCatSama

After upgrading "vue-slider-component" "2.4.1" to latest 3.0.33, getting error "Uncaught TypeError: Super expression must either be null or a function".

Below are the configuration of My current project.
Node - 10.16.4
Npm - 6.9.0
Yarn - 1.16.0

@ghost ghost added the bug label Jun 27, 2019
@NightCatSama
Copy link
Owner

Can you send the complete error stack?

Is there a possibility of circular dependencies?

@ghost
Copy link
Author

ghost commented Jun 27, 2019

@NightCatSama: Please verify

Uncaught TypeError: Super expression must either be null or a function
at x (vue-slider-component.umd.min.js?4971:6)
at eval (vue-slider-component.umd.min.js?4971:6)
at Module.fb15 (vue-slider-component.umd.min.js?4971:6)
at r (vue-slider-component.umd.min.js?4971:1)
at 2350 (vue-slider-component.umd.min.js?4971:1)
at eval (vue-slider-component.umd.min.js?4971:1)
at eval (vue-slider-component.umd.min.js?4971:1)
at eval (vue-slider-component.umd.min.js?4971:1)
at Object.599 (loanamountcalculator.build.js:756)
at webpack_require (loanamountcalculator.build.js:20)

@NightCatSama
Copy link
Owner

Sorry for the late reply.

It seems that the problem is not in the component, you can refer to this:

https://medium.com/@anuhosad/react-errors-super-expression-must-either-be-null-or-a-function-4aac6e5173ad

@syberon
Copy link

syberon commented Aug 6, 2019

I tried to use this component in my site that uses requirejs to load all modules. Vue library loads without any problems via requirejs but if i try to load vue-slider umd file as a module it gives me the same error "Uncaught TypeError: Super expression must either be null or a function". Is this any way to use it with requrejs?

@NightCatSama
Copy link
Owner

@syberon I don't know why 😢 , using umd specification package should support amd.

@syberon
Copy link

syberon commented Aug 6, 2019

This looks like when i trying to load the module it can not find globally defined Vue.
This is small example that works:

<html>
<head>
    <script src="/js/vue.js"></script>
    <script src="/js/vue-slider-component.umd.js"></script>
</script>
</head>
<body>
</body>
</html>

If i remove the inclusion of vue.js from the code i get the error that in topic of this tread:
vue-slider-component.umd.js:1187 Uncaught TypeError: Super expression must either be null or a function

This is code that i tried to use:

index,html

<html>
<head>
    <script type="text/javascript" charset="utf-8" data-main="/js/main.js" src="/js/require.js"></script>
</head>
<body>
</body>
</html>

main.js

require ([
    'vue',
    'vue-slider-component.umd'
], function (Vue) {
    new Vue({
        el: '#app'
    })
});

And this code gets to me the same error on 'vue-slider-component.umd' module loading:
vue-slider-component.umd.js:1187 Uncaught TypeError: Super expression must either be null or a function

It looks like the module tries to find the globally defined (or something else) Vue on load and throws this error if can't find it.

@NightCatSama
Copy link
Owner

@syberon Is it because of the loading order problem, you try this?

require (['vue'], function (Vue) {
    require(['vue-slider-component.umd'], function(VueSlider) {
       // new Vue
    })
});

@syberon
Copy link

syberon commented Aug 6, 2019

Yes, i tried this now, but without luck. Component still throw this error.

@NightCatSama
Copy link
Owner

@syberon Sorry, I have no clue 🤕 .

Do you want to try this?

vuejs/vue-cli#4084

// vue-slider-component.umd.js line: 5
define(['vue'], factory);

@syberon
Copy link

syberon commented Aug 7, 2019

Thanks! This trick worked for me.

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

No branches or pull requests

2 participants