JS错误:Cannot assign to read only property exports of object Object

今天更新了一下JavaScript依赖库,结果碰到莫名的错误,页面加载不出来,错误信息:

 Uncaught TypeError: Cannot assign to read only property 'exports' of object '#'
    at Module.eval (BaseClient.js?e917:12)
    at eval (BaseClient.js:42)
    at Module../node_modules/webpack-dev-server/client/clients/BaseClient.js (main.js:11977)
    at __webpack_require__ (main.js:769)
    at fn (main.js:130)
    at Module.eval (SockJSClient.js?810f:26)
    at eval (SockJSClient.js:138)
    at Module../node_modules/webpack-dev-server/client/clients/SockJSClient.js (main.js:11989)
    at __webpack_require__ (main.js:769)
    at fn (main.js:130)
 
  

查了好多资料好像是export和import共用了导致不兼容引起的!!!

最后找到个办法,试了一下可以用,特此记录:

npm install babel-plugin-transform-es2015-modules-commonjs

然后在根目录 babelrc文件中配置

 { "plugins": ["transform-es2015-modules-commonjs"] }

即可解决

你可能感兴趣的:(JS,javascript,node.js)