vue components use CommonJS 'module.exports'
See original GitHub issueVersion
13.7.0
Steps to reproduce
in vue component file, if i use the commonjs way to export
// error way
module.exports = {
name: 'component-name'
}
// normal write
export default {
}
Because of some historical writing
What is expected?
compile is ok.
What is actually happening?
find error
21:2-16 "export 'default' (imported as '__vue_script__') was not found in '!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./component-upload.vue'
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Problem using shared files with commonjs modules - Vue Forum
I am working on an existing application that uses shared javascript files in Vue and in Node. These files use commonjs modules (...
Read more >import and module.exports in Vuex module show Uncaught ...
VueJS is browser code and use ES6 modules import xxx from './path/to/xxx'; export xxx; export default xxx;. while CommonJS is used by NodeJS ......
Read more >How to Package and Distribute a Vue.js 3 Plugin on NPM
For common JS and ES modules to target the proper files you should provide the main, module, and exports options. (These files in...
Read more >CommonJS vs. ES modules in Node.js - LogRocket Blog
Node.js, however, supports the CommonJS module format by default. CommonJS modules load using require() , and variables and functions export ...
Read more >Building external modules in VueJS - Pusher Blog
When we create an external module, we can use the same module across ... export default { install(Vue, options) { Vue.component('user-pop', ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is anyway to support module.exports in vue-cli3 created project ? Because I would like to share some common module with frontend and backend.
14.0+ no longer supports
module.exports
. Useexport default
instead.