question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using xlsx with Webpack on the browser.

See original GitHub issue

I am using xlsx with Webpack on the browser.

import XSLX from "xslx";

Importing XSLX is throwing an error in Webpack compilation that fs module could not be found. screen shot 2016-09-08 at 2 21 11 pm

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
vijaystcommented, Sep 12, 2016

I found this answer on another thread. Add the below configuration to the webpack.config file.

// required for xlsx to work with webpack
  node: {
    fs: 'empty'
  },

  externals: [
    {
      './cptable': 'var cptable'
    },
    {
      './jszip': 'jszip'
    }
  ],
0reactions
dineshjain1992commented, Nov 13, 2017

@reviewher Here is my webpack.config file const webpack = require(‘webpack’); const HtmlWebpackPlugin = require(‘html-webpack-plugin’); const ExtractTextPlugin = require(‘extract-text-webpack-plugin’); var IgnorePlugin = require(‘watch-ignore-webpack-plugin’) var jquery = require(‘jquery’); var underscore = require(‘underscore’); var moment = require(‘moment’); const rules = [ { test: /.css$/, use: ExtractTextPlugin.extract({ fallback: “style-loader”, use: [“css-loader”] }) } ,{ test: /.(woff(2)?|ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/, //to support @font-face rule loader: “url-loader”, query:{ limit:‘10000’, name:‘font.css’, outputPath:‘fonts/’ //the fonts will be emmited to public/assets/fonts/ folder //the fonts will be put in the DOM <style> tag as eg. @font-face{ src:url(assets/fonts/font.ttf); }
} }, ]; const plugins = []

module.exports = { context: __dirname + ‘’, entry: { app: ‘./webpackApp.js’ , vendor: ‘./webpackJQ.js’ // , bundlejs: ‘./webpackJQ.js’ }, output: { path: __dirname + ‘/public/webpack-min’, filename: ‘bundle.js’ } , plugins: [ new webpack.ProvidePlugin({ ‘$’: “jquery”, ‘jQuery’: “jquery”, ‘jquery’: “jquery”, ‘window.$’: “jquery”, ‘window.jQuery’: “jquery”, “window.moment”: “moment”, “moment”: “moment”, ‘_’:‘underscore’, “underscore”: “underscore”, })

    ,new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.js',Infinity })
    ,new ExtractTextPlugin({ filename: "style.css" }),
]

,externals: [
	{
        'sampleApp': '',
		'./cptable': 'var cptable',
		'./jszip': 'jszip'
	}
]
,module: {
    rules
}
,node: {
    fs: 'empty'
  },

};

from my webpackJQ.js file I am using require(‘./public/asset/libs/js/xlsx.core.min.js’);

Did I miss something ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using xlsx with Webpack on the browser. · Issue #467 - GitHub
I am using xlsx with Webpack on the browser. import XSLX from "xslx";. Importing XSLX is throwing an error in Webpack compilation that...
Read more >
importing xlsx package shows module not found
I have installed xlsx 0.18.5 npm package to export xlsx files, I found out that's a webpack issue (https://github.com/SheetJS/sheetjs/issues/ ...
Read more >
Bundlers | SheetJS Community Edition
SheetJS predates ECMAScript modules and bundler tools like Webpack. As best. ... use XLSX . ... Both the node and browser platforms work...
Read more >
file-loader - webpack - JS.ORG
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
Create an .xlsx file in a browser | by Marian Čaikovski - Medium
The SheetJS package downloaded with command npm install xlsx includes several files. The complete SheetJS library is saved in file ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found