Vue: require a package :cannot assign to read only property 'exports' of object '#<Object>'

不想你离开。 提交于 2019-12-08 12:23:27

问题


I installed package resource-bundle in my project and now to use it in my main.js:

/*main.js*/
var co=require('co');
var loader = require('resource-bundle');
co(function*(){
   ...
   ...
}).catch(onerror);

And this is in the index.js of resource-bundle package:

 /*index.js*/
 module.exports = function*(locale, dir, baseName) {
    ...
    ...
    ...
 }

It gets this error:

Cannot assign to read only property 'exports' of object '#<Object>'

What's the problem?


回答1:


Why your module.exports is a function?

It should be Object Literal like this:

module.exports = {
key:"value",
intro:"my name is %s,in class %d",
mk:"%s%s%s"

}



来源:https://stackoverflow.com/questions/48731457/vue-require-a-package-cannot-assign-to-read-only-property-exports-of-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!