1. 首页
  2. >
  3. 前端开发
  4. >
  5. Vue

* ./cptable in ./node_modules/_xlsx-style@0.8.13@xlsx-style/dist/cpexcel.js

由于项目中用到了xlsx和xlsx-style,但正常安装后,出现以下错误:

* ./cptable in ./node_modules/_xlsx-style@0.8.13@xlsx-style/dist/cpexcel.js

而在npm install结果是正常的:

E:\web>npm install
√ Installed 83 packages
√ Linked 0 latest versions
√ Run 0 scripts
√ All packages installed (used 37ms(network 33ms), speed 0B/s, json 0(0B), tarball 0B) 

正常逻辑来说,应该不存在模块安装不成功的问题,但怎么回报错呢?

经过查找资料,发现这条可以解决这个问题:

I end up with couple of compile errors when using with angular-cli

ERROR in ./node_modules/xlsx-style/dist/cpexcel.js
Module not found: Error: Can't resolve 'cptable' in 'C:\buildareas\head\issdev\src\javascript\APFAnalytics\node_modules\xlsx-style\dist'
ERROR in ./node_modules/xlsx-style/ods.js
Module not found: Error: Can't resolve 'xlsx' in 'C:\buildareas\head\issdev\src\javascript\APFAnalytics\node_modules\xlsx-style'

I had to make couple of changes

  1. In cpexcel.js file change var cpt = require('./cptable') to var cpt = cptable
  2. In ods.js file change require('xlsx') to require('./xlsx')

The first change is actually fixed in the main SheetJs/js-xlsx library, since this is a fork of it we need to change it

Can the above two changes incorporated into the master? or do you want me to make a new fork of this and put my changes in?