I have a webpack config like:
var path = require('path')
module.exports = {
entry: "./index.js",
output: {
path: path.join(__dirname, 'static'),
filename:'bundle.js'
},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader"},
{ test: /\.json$/, loader: 'json-loader' },
]
},
node: {
fs: "empty"
}
};
And I want to read a file using fs
I am doing something like:
var fs = require('fs')
console.log(fs)
fs.readFile('input.txt', function (err, buffer) {
console.log("buffer")
console.log(buffer)
})
I just want to read a file here but when I do this it gives me error saying:
fs.readFile
is not a function
I have installed fs
using npm install --save fs
Also when I print fs
it gives me empty object.
Above I have done console.log(fs)
it is giving me empty object
What is wrong in here?