*When I try to run the npm run dev
command, I get the following error:
*
[Error: Cannot find module 'next/dist/compiled/ws' Require stack:
/mnt/c/Users/Marcus Flavio/OneDrive - Microsoft 365/Área de Trabalho/Projects/smartiming-pwa/node_modules/next/dist/server/dev/hot-reloader-webpack.js
/mnt/c/Users/Marcus Flavio/OneDrive - Microsoft 365/Área de Trabalho/Projects/smartiming-pwa/node_modules/next/dist/server/lib/router-utils/setup-dev-bundler.js
/mnt/c/Users/Marcus Flavio/OneDrive - Microsoft 365/Área de Trabalho/Projects/smartiming-pwa/node_modules/next/dist/server/lib/router-server.js
/mnt/c/Users/Marcus Flavio/OneDrive - Microsoft 365/Área de Trabalho/Projects/smartiming-pwa/node_modules/next/dist/server/lib/start-server.js
] { code: 'MODULE_NOT_FOUND', requireStack: [Array] }
*next.config.js file configuration:
*
const withPWA = require("@ducanh2912/next-pwa").default({
dest: "public",
cacheOnFrontEndNav: true,
aggressiveFrontEndNavCaching: true,
reloadOnOnline: true,
swcMinify: true,
disable: process.env.NODE_ENV === "development",
workboxOptions: {
disableDevLogs: true,
},
swSrc: "public/serviceWorker.js",
});
/** @type {import('next').NextConfig} */
const nextConfig = {
typescript: {
tsconfigPath: "./tsconfig.json",
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "**.**.**",
},
],
},
webpack(config) {
config.resolve.alias = {
...config.resolve.alias,
"@": require("path").resolve(__dirname),
};
return config;
},
};
module.exports = withPWA(nextConfig);
Development environment
System: WSL on Windows
Node.js: v22.13.1
Next.js: v15.1.6
*Troubleshooting steps taken:
*
1- Added experimental configuration in next.config.js
:
experimental: {
outputFileTracingRoot: join(__dirname, '../../'),
}
2- Cleared cache and removed temporary directories:
rm -rf .next && npm cache clean --force
3- Removednode_modules
andpackage-lock.json
and reinstalled dependencies:
rm -rf node_modules package-lock.json
npm install
*None of these solutions worked. Has anyone faced this error or has suggestions?
*
Top comments (1)
No solution (Sorry).
I have same problem on Ubuntu 24.04 LTS with :
Node.js: v22.14.0
Next.js: v15.1.7
So interested if someone has an idea ...
NB : I am a Newbie on Node.js and Next.js