2.在使用"node-xlsx" 模块时报" TypeError: Object function Object() { [native code] } has no method 'assign' "


最近做一个关于数据库数据以xls格式导出的功能。由于之前用的"excel-export"模块功能有不是很全。也有可能是我没完全弄明白怎么使用这个模块生成多页的excel文件吧。后来就选用了'node-xlsx'模块来做。但是在使用demo的时候,会报一个TypeError: Object function Object() { [native code] } has no method 'assign的错误。网上查了半天也没找到相关信息。后来终于找到一篇文章。(链接:https://www.cnblogs.com/theswiftworld/p/node-object-assign.html)。里面的一语句话告诉了我原因:"老版本的 ECMAScript 6 以下引擎是不支持 Object.assign 函数的."然后我恍然大悟,原来是我的node版本太低了。找到原因,现在来解决吧。

1.首先把'object-assign'模块下载下来。(具体的下载方法,我就不多说了,相信写node的人都知道)

2.把这个模块里面的方法替换掉'node-xlsx'模块中使用的assign()方法即可。

好了,这样就完美解决问题了。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



猜您在找 Vue 使用自定义组件时报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#' node.js中使用node-xlsx插件生成excel数据并导出 'builtin_function_or_method' object has no attribute 'translate' TypeError: 'method' object is not iterable 报错信息:AttributeError: 'builtin_function_or_method' object has no attribute 'random' Uncaught (in promise) TypeError: Object(...) is not a function (node:18692) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Object.entries is not a function 的解决方法 踩坑记录-安装node-sass运行报错TypeError: this.getResolve is not a function at Object.loader Uncaught TypeError: Cannot assign to read only property 'exports' of object '#' 用jqgrid时报错,Uncaught TypeError: $(…).jqGrid is not a function
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM