1
我正在開發一個帶有webpack的網站。當我有這樣的代碼:webpack:在同一模塊導入+ module.exports導致錯誤
import $ from 'jquery';
function foo() {};
module.exports = foo;
我得到了錯誤Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
。
原來,import $ from 'jquery'
更改爲var $ = require('jquery')
不會導致任何錯誤。
爲什麼使用module.exports導入會導致此錯誤?反而使用require有什麼不妥?
的可能的複製[使用Node.js的要求與ES6導入/導出](http://stackoverflow.com/questions/31354559/using-node-js-require-vs-es6-import-export ) –
@MatthewHerbst改變了主要問題。 – juniorgarcia