I, am trying to use the fs module but I get this error
Module not found: Error: Can't resolve 'fs' in '/home/pau/Escritorio/Master/Blockchain/Prac2/PRAC2_Template/Ejercicio_2/app/src'
@ ./src/index.js 5:11-24
I have fs installed and for what I've seen, theres a problem with webpack that makes this happen.
Mi packeage.json is this
{
"name": "app",
"version": "1.0.0",
"description": "",
"private": true,
"scripts": {
"build": "webpack",
"dev": "webpack-dev-server"
},
"devDependencies": {
"copy-webpack-plugin": "^5.0.5",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0"
},
"dependencies": {
"fs": "0.0.1-security",
"ipfs-http-client": "^47.0.0",
"web3": "^1.8.1"
}
}
and my webpack.config.js this
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = {
entry: "./src/index.js",
output: {
filename: "index.js",
path: path.resolve(__dirname, "dist"),
},
plugins: [
new CopyWebpackPlugin([{ from: "./src/index.html", to: "index.html" }]),
],
devServer: { contentBase: path.join(__dirname, "dist"), compress: true },
};
I found this link https://github.com/webpack/webpack/issues/13498, where they say that adding
module: {
rules: [
{
test: /@aws-sdk\/lib-storage\//,
resolve: {
alias: {
'./runtimeConfig': './runtimeConfig.browser',
},
},
},
],
},
The problem disappear, but it doesnt work for me. My webpack.config.js with that code looks like this:
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = {
entry: "./src/index.js",
output: {
filename: "index.js",
path: path.resolve(__dirname, "dist"),
},
plugins: [
new CopyWebpackPlugin([{ from: "./src/index.html", to: "index.html" }]),
],
devServer: { contentBase: path.join(__dirname, "dist"), compress: true },
module: {
rules: [
{
test: /@aws-sdk\/lib-storage\//,
resolve: {
alias: {
'./runtimeConfig': './runtimeConfig.browser',
},
},
},
],
},
};
But I get the same error.
How can I solve this?