Upgrading from 9.2.1 --> 9.3.5 "Error: Cannot find module 'next/dist/next-server/lib/fid.js'"
See original GitHub issueTrying to upgrade from 9.2.1 to latest stable release (9.3.5). Node Version: 10.16
Compiles successfully in terminal, but when opening localhost:port, I’m getting the following:
[ ready ] compiled successfully - ready on http://localhost:7778
{ Error: Cannot find module 'next/dist/next-server/lib/fid.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.../next-server/lib/fid (C:\Users\Wade\Documents\GitHub\myodesign\dist\functions\next\server\static\development\pages\_document.js:136:18)
at __webpack_require__ (C:\Users\Wade\Documents\GitHub\myodesign\dist\functions\next\server\static\development\pages\_document.js:23:31)
at Object../node_modules/next/dist/pages/_document.js (C:\Users\Wade\Documents\GitHub\myodesign\dist\functions\next\server\static\development\pages\_document.js:192:35)
at __webpack_require__ (C:\Users\Wade\Documents\GitHub\myodesign\dist\functions\next\server\static\development\pages\_document.js:23:31)
at Object../node_modules/next/document.js (C:\Users\Wade\Documents\GitHub\myodesign\dist\functions\next\server\static\development\pages\_document.js:878:18)
at __webpack_require__ (C:\Users\Wade\Documents\GitHub\myodesign\dist\functions\next\server\static\development\pages\_document.js:23:31)
at Module../pages/_document.js (C:\Users\Wade\Documents\GitHub\myodesign\dist\functions\next\server\static\development\pages\_document.js:895:71)
at __webpack_require__ (C:\Users\Wade\Documents\GitHub\myodesign\dist\functions\next\server\static\development\pages\_document.js:23:31)
at Object.1 (C:\Users\Wade\Documents\GitHub\myodesign\dist\functions\next\server\static\development\pages\_document.js:996:18)
at __webpack_require__ (C:\Users\Wade\Documents\GitHub\myodesign\dist\functions\next\server\static\development\pages\_document.js:23:31)
at module.exports.../../node_modules/common/src/assets/image/favicon-32.png.module.exports (C:\Users\Wade\Documents\GitHub\myodesign\dist\functions\next\server\static\development\pages\_document.js:91:18)
at Object.<anonymous> (C:\Users\Wade\Documents\GitHub\myodesign\dist\functions\next\server\static\development\pages\_document.js:94:10) code: 'MODULE_NOT_FOUND' }
next.config
const withPlugins = require("next-compose-plugins");
const withTM = require("next-transpile-modules");
const withOptimizedImages = require("next-optimized-images");
const withFonts = require("next-fonts");
const withCSS = require("@zeit/next-css");
module.exports = {
webpack: (config, { isServer }) => {
// Fixes npm packages that depend on `fs` module
if (!isServer) {
config.node = {
fs: "empty"
};
}
return config;
}
};
module.exports = withPlugins(
[
[
withTM,
{
transpileModules: ["reusecore", "common"]
}
],
[
withOptimizedImages,
{
mozjpeg: {
quality: 90
},
webp: {
preset: "default",
quality: 90
}
}
],
withFonts,
withCSS
],
{
distDir: "../../dist/functions/next"
}
);
_document.js
import Document, { Html, Head, Main, NextScript } from "next/document";
import { ServerStyleSheet } from "styled-components";
import FavIcon from "common/src/assets/image/favicon-32.png";
export default class CustomDocument extends Document {
static async getInitialProps(ctx) {
const sheet = new ServerStyleSheet();
const originalRenderPage = ctx.renderPage;
try {
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: App => props => sheet.collectStyles(<App {...props} />)
});
const initialProps = await Document.getInitialProps(ctx);
return {
...initialProps,
styles: (
<>
{initialProps.styles}
{sheet.getStyleElement()}
</>
)
};
} finally {
sheet.seal();
}
}
render() {
return (
<html lang="en">
<Head>
<link rel="shortcut icon" type="image/x-icon" href={FavIcon} />
</Head>
<body>
<Main />
<NextScript />
</body>
</html>
);
}
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:15
- Comments:21 (4 by maintainers)
Top Results From Across the Web
How do I resolve "Cannot find module" error using Node.js?
Using npm install installs the module into the current directory only (in a subdirectory called node_modules ). Is app.js located under ...
Read more >How to fix Laravel 9 Vite Cannot find module 'node:path' error
... try restarting your device. Your browser can't play this video. ... How to fix Laravel 9 Vite Cannot find module 'node:path' error....
Read more >cannot find module [Node npm Error Solved] - freeCodeCamp
In this article, I'm going to show you how to fix the error. Why the "Error: cannot find module" Occurs. This error occurs...
Read more >After WIN Update, Error: cannot find module xrWCbgnd.dll
Hello, After windows update (27.5.2018): "Windows 10, Ver 1803" An ERROR message keeps poping up in WIND's startup: "Error: cannot find ...
Read more >[solved] Some package update completely breaks my app ...
So I did a standard meteor update: iMac:app patrick$ meteor update ... package update completely breaks my app (cannot find module core-js).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Here I solved by doing
ctrl + shift + p> TypeScript: Restart TS serverDelete
node_modulesfolder and runnpm iagain, worked for me! 😃