Currently, I am immersed in a nextjs project using wagmi hooks. Recently, Nextjs presented me with an error message indicating that it cannot resolve the 'module' (refer to the error message below). This occurred after resolving the initial errors related to the missing 'fs module' and 'child_process module' by incorporating a fallback statement in my next.config.js file.
Within my project, I employ wagmi hooks for interactions with deployed smart contracts. I have a suspicion that this might have triggered the chain of error messages. Any assistance or guidance on this matter would be greatly appreciated. Thank you!
Error message:
./node_modules/eslint-config-next/index.js:42:0 Module not found: Can't resolve 'module'
Reference code in /eslint-config-next/index.js:42:0
const mod = require('module')
const resolveFilename = mod._resolveFilename
mod._resolveFilename = function (request, parent, isMain, options) {
const hookResolved = hookPropertyMap.get(request)
if (hookResolved) {
request = hookResolved
}
return resolveFilename.call(mod, request, parent, isMain, options)
}
Here is a snippet from my next.config.js:
const nextConfig = {
reactStrictMode: true,
// The following was added to suppress the initial 'fs module not found' and 'child_process module not found' errors
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback.fs = false;
config.resolve.fallback.tls = false;
config.resolve.fallback.net = false;
config.resolve.fallback.child_process = false;
}
return config;
},
future: {
webpack5: true,
},
fallback: {
fs: false,
tls: false,
net: false,
child_process: false,
},
};
module.exports = nextConfig;
This is an excerpt from my package.json:
{
"name": "slot_next",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@next/font": "13.1.2",
"@nodelib/fs.scandir": "^2.1.5",
"@rainbow-me/rainbowkit": "^0.8.1",
"eslint": "8.31.0",
"eslint-config-next": "13.1.2",
"ethers": "^5.7.2",
"next": "13.1.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"wagmi": "^0.9.6"
},
"devDependencies": {
"autoprefixer": "^10.4.13",
"postcss": "^8.4.21",
"tailwindcss": "^3.2.4"
}
}
In an attempt to troubleshoot, I executed both npm cache clear --force
and npm install
, but unfortunately, that did not alleviate the issue.