nit: ask user to modify devOptions.port when addr in use for dev (#347)
* nit: ask user to modify devOptions.port when addr in use for dev * unnecessary import of red * changeset
This commit is contained in:
parent
26853fd2ec
commit
5fbc1cb641
2 changed files with 19 additions and 5 deletions
5
.changeset/stupid-dryers-bow.md
Normal file
5
.changeset/stupid-dryers-bow.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
nit: ask user to modify devOptions.port when addr in use for dev
|
|
@ -101,9 +101,18 @@ export default async function dev(astroConfig: AstroConfig) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const port = astroConfig.devOptions.port;
|
const port = astroConfig.devOptions.port;
|
||||||
server.listen(port, hostname, () => {
|
server
|
||||||
const endServerTime = performance.now();
|
.listen(port, hostname, () => {
|
||||||
info(logging, 'dev server', green(`Server started in ${Math.floor(endServerTime - startServerTime)}ms.`));
|
const endServerTime = performance.now();
|
||||||
info(logging, 'dev server', `${green('Local:')} http://${hostname}:${port}/`);
|
info(logging, 'dev server', green(`Server started in ${Math.floor(endServerTime - startServerTime)}ms.`));
|
||||||
});
|
info(logging, 'dev server', `${green('Local:')} http://${hostname}:${port}/`);
|
||||||
|
})
|
||||||
|
.on('error', (err: NodeJS.ErrnoException) => {
|
||||||
|
if (err.code && err.code === 'EADDRINUSE') {
|
||||||
|
error(logging, 'dev server', `Address ${hostname}:${port} already in use. Try changing devOptions.port in your config file`);
|
||||||
|
} else {
|
||||||
|
error(logging, 'dev server', err.stack);
|
||||||
|
}
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue