vue引用xlsx-style组件 报错:This relative module was not found: ./cptable in ./node_modules/xlsx-style

本文讲述了在Vue项目中使用xlsx-style组件导出Excel时遇到的'notfound./cptable'innode_modules/xlsx-style/dist/cpexcel.js错误,通过查找发现是由于文件路径错误导致。解决办法包括直接修改本地文件和在webpack配置中外部引入。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这个是前端 vue 中的 Excel 文件导出时用到的

程序启动的时候出现错误,显示:not found ./cptable in node_modules/xlsx-style/dist/cpexcel.js
这个不是程序的问题,而是,在该文件目录下面,有段程序写错了,

在该js文件里,第807行,var cpt = require(’./cpt’ + ‘able’);有误,

改成 var cpt = cptable; 就可以正确启动程序了

问题所在:\node_modules\xlsx-style\dist\cpexcel.js 807行   var cpt = require('./cpt' + 'able');

解决方案1: 修改为  var cpt = cptable  修改的只是本地文件

解决方案2:webpack.base.conf.js 

module.exports = {
    externals: [ {
         './cptable': 'var cptable' 
    }]
}
 

参考链接:

not found cptable in node_modules/xlsx-style/dist/cpexcel.js

https://blog.youkuaiyun.com/qq_24044863/article/details/100011265

 

vue引用xlsx-style组件 报错:This relative module was not found: ./cptable in ./node_modules/xlsx-style

https://blog.youkuaiyun.com/jing_mama/article/details/108362669

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值