Can't use this package on browser
See original GitHub issueI’m trying to use exceljs
on browser to read some XLSX files.
But, when I tried to import using
import Excel from 'exceljs';
I received an error on build because can’t resolve fs
module:
ERROR in ./node_modules/exceljs/dist/es5/csv/csv.js
Module not found: Error: Can't resolve 'fs' in '/my-project/node_modules/exceljs/dist/es5/csv'
ERROR in ./node_modules/exceljs/dist/es5/utils/utils.js
Module not found: Error: Can't resolve 'fs' in '/my-project/node_modules/exceljs/dist/es5/utils'
ERROR in ./node_modules/exceljs/dist/es5/xlsx/xlsx.js
Module not found: Error: Can't resolve 'fs' in '/my-project/node_modules/exceljs/dist/es5/xlsx'
...
Searching about how is the correct way to import on browser, I found this example, and following it I tried importing using
const ExcelJS = require('exceljs/dist/es5/exceljs.browser');
But this command also didn’t work, returning the same errors.
Also I found a related open issue about this problem.
Then… is there a way to import exceljs
on browser?
Issue Analytics
- State:
- Created 4 years ago
- Comments:24 (3 by maintainers)
Top Results From Across the Web
How to use npm modules in browser? is possible to use them ...
I'm new to npm module and node.js so it is really difficult to me. I have a js code whit many points and...
Read more >I'm unable to install the Connective browser package
Possible cause, Solution. You're using an operating system that is not or no longer supported. Use an officially supported operating system.
Read more >Troubleshooting - Unity - Manual
For example, if the Package Manager can't access the package registry server, it displays this message in the status bar: Network error message....
Read more >@azure/msal-browser - npm
See here for more info on how to use this package from the Microsoft CDN. Usage. Migrating from Previous MSAL Versions.
Read more >Troubleshooting | Cypress Documentation
If Cypress cannot find a browser but you know you have it installed, there are ways to ensure that Cypress can "see" it....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I solved this by adding:
declare const ExcelJS: any;
and in
angular.json
:"scripts": [ ... "node_modules/exceljs/dist/exceljs.min.js" ]
Hi @abmj1979, Thanks, it’s working now. What I didn’t understand is why the line
declare const ExcelJS: any;
should be there.Also, why we need to add
exceljs.min.js
in angular.json if we are already using it as an import in our service.