Unverified Commit f8308c9e authored by Yagiz Nizipli's avatar Yagiz Nizipli Committed by GitHub

fix: avoid unnecessary `existSync` call (#56419)

Co-authored-by: 's avatarJiachi Liu <inbox@huozhi.im>
parent b436589f
...@@ -367,8 +367,8 @@ export default class NextNodeServer extends BaseServer { ...@@ -367,8 +367,8 @@ export default class NextNodeServer extends BaseServer {
const buildIdFile = join(this.distDir, BUILD_ID_FILE) const buildIdFile = join(this.distDir, BUILD_ID_FILE)
try { try {
return fs.readFileSync(buildIdFile, 'utf8').trim() return fs.readFileSync(buildIdFile, 'utf8').trim()
} catch (err) { } catch (err: any) {
if (!fs.existsSync(buildIdFile)) { if (err.code === 'ENOENT') {
throw new Error( throw new Error(
`Could not find a production build in the '${this.distDir}' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id` `Could not find a production build in the '${this.distDir}' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id`
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment