Мой код js:
ar fs = require('fs')
fs.readFile('./content.json', 'utf-8', function(err, data) {
if (err) throw err;
})
Webpack.config.js:
// var webpackUglifyJsPlugin = require('webpack-uglify-js-plugin');
module.exports = {
node: { net: 'empty',
tls: 'empty',
module: 'empty',
},
watch: true,
entry: {
mainpage: __dirname + '/src/scripts/mainpage.jsx',
goods: __dirname + '/src/scripts/goods.jsx',
common: __dirname + '/src/scripts/common.jsx',
data_models: __dirname + '/src/scripts/data_models.js'
},
output: {
filename: '[name].js',
path: __dirname + '/dist/scripts'
},
module: {
rules: [
{
test: /(.jsx|.js)$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/,
query: {
presets: ['es2015', 'react']
}
}
]
}
};
Код ошибки:
ERROR in ./src/scripts/data_models.js
Module not found: Error: Can't resolve 'fs' in '/media/monx94/(Внешний жёсткий диск)/ИнтернетМагазин/src/scripts'
@ ./src/scripts/data_models.js 8:9-22
ERROR in ./src/scripts/dispenser.js
Module not found: Error: Can't resolve 'fs' in '/media/monx94/(Внешний жёсткий диск)/ИнтернетМагазин/src/scripts'
@ ./src/scripts/dispenser.js 3:9-22
@ ./src/scripts/components.jsx
@ ./src/scripts/goods.jsx
ERROR in ./~/mongodb/lib/gridfs/grid_store.js
Module not found: Error: Can't resolve 'fs' in '/media/monx94/(Внешний жёсткий диск)/ИнтернетМагазин/node_modules/mongodb/lib/gridfs'
@ ./~/mongodb/lib/gridfs/grid_store.js 42:7-20
@ ./~/mongodb/index.js
@ ./src/scripts/data_models.js
ERROR in ./~/require_optional/index.js
Module not found: Error: Can't resolve 'fs' in '/media/monx94/(Внешний жёсткий диск)/ИнтернетМагазин/node_modules/require_optional'
@ ./~/require_optional/index.js 2:7-20
@ ./~/mongodb-core/lib/topologies/server.js
@ ./~/mongodb-core/index.js
@ ./~/mongodb/index.js
@ ./src/scripts/data_models.js
ERROR in ./~/resolve-from/index.js
Module not found: Error: Can't resolve 'module' in '/media/monx94/(Внешний жёсткий диск)/ИнтернетМагазин/node_modules/resolve-from'
@ ./~/resolve-from/index.js 3:13-30
@ ./~/require_optional/index.js
@ ./~/mongodb-core/lib/topologies/server.js
@ ./~/mongodb-core/index.js
@ ./~/mongodb/index.js
@ ./src/scripts/data_models.js
Ошибка в браузере
Uncaught Error: Cannot find module "fs"
Пробовал ставить "node: {fs: empty}", не помогает.
В чём может быть проблема?