Node: better serverEntrypoint error (#5560)
* fix(node): better entrypoint error * fix(node): surface start errors during preview Co-authored-by: Nate Moore <nate@astro.build>
This commit is contained in:
parent
02bb0a1ccd
commit
281ea9fc34
2 changed files with 13 additions and 4 deletions
5
.changeset/nice-pens-lie.md
Normal file
5
.changeset/nice-pens-lie.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/node': patch
|
||||
---
|
||||
|
||||
Improve error message when serverEntrypoint does not exist
|
|
@ -24,10 +24,14 @@ const preview: CreatePreviewServer = async function ({
|
|||
`The server entrypoint doesn't have a handler. Are you sure this is the right file?`
|
||||
);
|
||||
}
|
||||
} catch (_err) {
|
||||
throw new Error(
|
||||
`The server entrypoint ${fileURLToPath} does not exist. Have you ran a build yet?`
|
||||
);
|
||||
} catch (err) {
|
||||
if ((err as any).code === 'ERR_MODULE_NOT_FOUND') {
|
||||
throw new Error(
|
||||
`The server entrypoint ${fileURLToPath(serverEntrypoint)} does not exist. Have you ran a build yet?`
|
||||
);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
const handler: http.RequestListener = (req, res) => {
|
||||
|
|
Loading…
Reference in a new issue