deno
deno copied to clipboard
Can't the "--watch" option be used on a listening port?
/**
* deno.jsonc
*/
{
"tasks": {
"dev": "deno run -A --watch main.js"
},
"imports": {
"koa": "npm:[email protected]",
"koa-router": "npm:[email protected]",
"koa-static": "npm:[email protected]"
}
}
/**
* main.js
*/
import Koa from "koa"
import Router from "koa-router"
const app = new Koa()
const router = new Router()
router.prefix("/api")
router.get("/", (ctx, _next) => {
console.log("home1")
ctx.body = {
msg: "hello world!",
}
})
app
.use(router.routes())
.use(router.allowedMethods())
.listen(1993, err => {
if (err) throw err
console.log("http://localhost:1993/api")
})
After running deno task dev, it is normal for the first time, and then change the content of main.js, for example, change console.log("home") to console.log("home2"), and an error will be reported on the terminal: Watcher File change detected! Restarting! error: Uncaught AddrInUse: 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 (os error 10048) Watcher Process finished. Restarting on file change...
Deno uses npm's koa, and when the mouse hovers over its methods or properties, there is no hint of its API usage
This is a known bug, hopefully it is fixed soon. https://github.com/denoland/deno/issues/16267
This was fixed in v1.32.4.