Webpack Error: Cannot assign to read the property ' exports ' of object ' #<object> '

Source: Internet
Author: User

This unfortunate mistake was very successful when it was developed on Mac computers, but it was an error when using Windows.

Baidu can't find, Google a check sure there is.

The reason: The code above is OK. You can mix and require export . You can ' t mix and import module.exports .

In other words, when webpack packaging, you can mix require and export in JS files. But you can't mix import and Module.exports.

So check the code, in their own main.js this section of code:

Import selector from '. /packages/selector '; Import alert from '. /packages/alert '; const components=[    selector,    alert,]const install=function (vue,option={}) {    Components.map (component = {        vue.component (component.name, component);    })    Vue.prototype. $alert =alert;    Vue.prototype. $info =alert.error;    Vue.prototype. $error =alert.error;} module.exports={    version: ' 0.0.1 ',    Install,}

This code uses the import statement at the very beginning, but finally uses the Module.exports statement. So it's an error.

Correct it:

var selector = require ('.. /packages/selector '); var alert=require ('.. /packages/alert '); const components=[    selector,    alert,]const install=function (vue,option={}) {    Components.map (component = {        vue.component (component.name, component);    })    Vue.prototype. $alert =alert;    Vue.prototype. $info =alert.error;    Vue.prototype. $error =alert.error;} module.exports={    version: ' 0.0.1 ',    Install,}

It's done.

So remind me to use require and module.exports as well as import and export default for future pairing.

Don't mix, save the problem.

Webpack Error: Cannot assign to read the property ' exports ' of object ' #<object> '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.