next.js: Cannot find module `pages/_document`
Bug report
Describe the bug
Upgrading to 7 from 6 and application works fine in development mode. In production, all pages fail with the server error Cannot find module '/app/.next/server/static/ddabb420240ac61ad07cc315c21cfa96e55c20df/pages/_document'.
Not using a custom document, but am using a custom _app.js. Verified that _document.js exist at that path in .next.
To Reproduce
Upgrade to Next 7.
Expected behavior
Pages should load without the error.
System information
package.json:
"dependencies": {
"@babel/core": "7.1.0",
"@babel/register": "7.0.0",
"@fortawesome/fontawesome-svg-core": "1.2.4",
"@fortawesome/free-brands-svg-icons": "5.3.1",
"@fortawesome/free-regular-svg-icons": "5.3.1",
"@fortawesome/free-solid-svg-icons": "5.3.1",
"@fortawesome/react-fontawesome": "0.1.3",
"@zeit/next-css": "1.0.1",
"aws-sdk": "2.317.0",
"babel-plugin-inline-import": "3.0.0",
"babel-plugin-inline-svg": "1.0.0",
"clipboard": "2.0.1",
"css-loader": "1.0.0",
"csv-parse": "3.0.0",
"enum": "2.5.0",
"file-loader": "1.1.11",
"js-md5": "0.7.3",
"luxon": "1.3.3",
"newrelic": "4.8.1",
"next": "7.0.0",
"path-match": "1.2.4",
"promise-file-reader": "1.0.2",
"react": "16.5.2",
"react-autosuggest": "9.4.1",
"react-dom": "16.5.2",
"react-load-script": "0.0.6",
"react-phone-number-input": "2.2.5",
"react-places-autocomplete": "7.2.0",
"react-tagsinput": "3.19.0",
"socket.io-client": "2.1.1",
"sw-loader": "0.1.2",
"timeago.js": "3.0.2",
"uuid": "3.3.2"
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 4
- Comments: 25 (11 by maintainers)
Got this issue after importing nonexistent file in my
page/_documentand using it in the render function. There were no any import error, onlyCannot find module pages/_document. After fixing the import error everything works fine.To get a detailed error message in
_documentI renamed it to document page and openedmyhost/document.This is not a clear and concise reproduction of the issue.
I had similar issue, had a syntax error in
_document.js. Fixed it and moved ahead.This comment helped
I have the same error. It’s just because of Link having 2 children. Good luck!
@timneutkens What about
???