I just ran a previous demo of Vue+webpack. After running, there was no expected effect and an error was reported.
Uncaught TypeError: Cannot assign to read only property’exports’ of object’#<Object>’
Click on the wrong file and mark the wrong place as this piece of code:
import {normalTime} from'./timeFormat'; module.exports = { normalTime };
Is module.exports;
The reason is: The code above is ok. You can mix and . You can’t mix and . require
export
import
module.exports
there is nothing wrong with the code. When webpack is packaged, you can mix require and export in the js file. But import and module.exports cannot be mixed.
Because import and module.exports are not allowed to be mixed in webpack 2,
The solution is to change it to ES6.
import {normalTime} from'./timeFormat' ; export default normalTime;
Finally it runs successfully.
Read More:
- [Solved] Vue + uniapp Uncaught TypeError: Cannot read property ‘getters‘ of undefined
- Vue ElementUI el-dropdown Error: Uncaught TypeError: Cannot read property ‘disabled‘ of null
- [Solved] Vue Error: Uncaught TypeError: Cannot read property ‘getters‘ of undefined
- Wechat program typeerror: a solution to cannot read property ‘SetData’ of undefined
- Vue Error in callback for immediate watcher “height”: “TypeError: Cannot read property ‘style’ of
- [Solved] vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: “TypeError: Cannot read property ‘length‘
- Uncaught (in promise) Error: Delete success at __webpack_exports__.default 405 error
- Vue error in render: “typeerror: cannot read property ‘length’ of undefined”
- VUE Echarts Loading Error TypeError: Cannot read property getAttribute of null?
- [Solved] TypeError: Cannot read property ‘indexOf‘ of undefined at VueComponent.resetFields
- [Vue warn]: Error in render: TypeError: Cannot read property ‘xxxx’of undefined
- [Solved] VUE Use Filters Error: [Vue warn]: Error in render: “TypeError: Cannot read property ‘toFixed’ of undefined”
- Uniapp: TypeError: Cannot read property ‘apply‘ of undefined (H5 does not report an error, but the real machine runs with an error)
- [Solved] uview u-sticky Error: Cannot read property ‘bottom‘ of null
- [Solved] swiper Error: The requested module ‘react’ is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export
- [Solved] Cannot read properties of undefined (reading ‘ajax‘); Cannot read property ‘ajax‘ of undefined
- Can’t read property ‘push’ of undefined [How to Solve]
- cesium CLAMP_TO_GROUND Error Cannot read property ‘globe‘ of undefined
- openlayers — Cannot read property ‘slice‘ of null—Map cannot be loaded
- El-cascader error: Cannot read property’level’ of null