question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vue components use CommonJS 'module.exports'

See original GitHub issue

Version

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:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

26reactions
sj82516commented, Aug 24, 2018

Is anyway to support module.exports in vue-cli3 created project ? Because I would like to share some common module with frontend and backend.

1reaction
yyx990803commented, Jul 4, 2018

14.0+ no longer supports module.exports. Use export default instead.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found