Vue: require a package :cannot assign to read only

2019-06-11 13:06发布

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条回答
2楼-- · 2019-06-11 13:35

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"

}

查看更多
登录 后发表回答