Open jcabannes opened 5 years ago
try installing from the repo directly, github:protobi/js-xlsx
@pietersv I put the repo url in my package.json
( I tried "github:protobi/js-xlsx", "git+https://github.com/protobi/js-xlsx.git" and "https://github.com/protobi/js-xlsx.git") but it does not fix theses errors.
After doing some research, I found that the problem is with Angular 6. Apparently, the node modules polyfills from webpack are not bundled (crypto and fs in this case).
Here is where i found the answer: https://github.com/angular/angular/issues/23398#issuecomment-386807572.
While you still can build some node polyfill modules that have browser or mock implementation, some are not available (like fs):
To import a built-in module, use non_webpack_require, i.e. non_webpack_require('modulename') instead of require('modulename').
Source: https://webpack.js.org/configuration/node/#other-node-core-libraries.
Here is a list of the node code libs for browser usage: https://github.com/webpack/node-libs-browser#readme
I installed xlsx-style in my angular 6 app via yarn and I get errors when I build my app :
ERROR in ../node_modules/xlsx-style/dist/cpexcel.js Module not found: Error: Can't resolve './cptable' in 'C:\Users\cabannesj\Documents\Virga3\virga-frontend\node_modules\xlsx-style\dist' ERROR in ../node_modules/xlsx-style/xlsx.js Module not found: Error: Can't resolve 'fs' in 'C:\Users\cabannesj\Documents\Virga3\virga-frontend\node_modules\xlsx-style' ERROR in ../node_modules/xlsx-style/ods.js Module not found: Error: Can't resolve 'fs' in 'C:\Users\cabannesj\Documents\Virga3\virga-frontend\node_modules\xlsx-style'
I added 'xlsx.core.min.js' in the script section of my angular.json file