Node.js 为什么它会给出一个错误节点expressjs?

Node.js 为什么它会给出一个错误节点expressjs?,node.js,express,unexpected-token,Node.js,Express,Unexpected Token,当我通过nodemon运行这段代码时出现了一个问题,它给出了以下错误 app.post('/register',async (req,res)=>{ try { const hashedPassword =await bcrypt.hash(req.body.password,10); users.push({ id: Date.now().toString(), name: req.body.name, email:req.

当我通过nodemon运行这段代码时出现了一个问题,它给出了以下错误

app.post('/register',async (req,res)=>{
try {
    const hashedPassword =await bcrypt.hash(req.body.password,10);
    users.push({
        id: Date.now().toString(),
        name: req.body.name,
        email:req.body.email,
        password:hashedPassword

    });
    res.redirect('/login')
    }
catch {

      res.redirect('/register')
      }

console.log(users)
`});``

try的正确语法。。。捕获如下

try {
   //do something
} catch (err) {
  console.error(err);
}

最后还有一堆`字,但我认为这只是你问题中的格式问题。是一个参考。

错误是什么?/home/hp/projects/L/login/server.js:28 catch{^SyntaxError:Unexpected token{at-createScript(vm.js:80:10)at-Object.runinthiscoxt(vm.js:139:10)at-Module.\u-compile(Module.js:616:28)at-Object.Module.\u-extensions...js(Module.js:663:10)at-Module.load(Module.js:565:32)at-trymodule.js:505:12)在Function.Module.加载(Module.js:497:3)在Function.Module.runMain(Module.js:693:10)启动(bootstrap_node.js:188:16)在bootstrap_node.js:609:3[nodemon]应用程序崩溃-在启动前等待文件更改