类型``Request <ParamsDictionary>''NodeJS上不存在属性''

时间:2020-06-29 08:02:21

标签: javascript node.js

尝试在app.get上执行简单的res.send('hello')时出现以下错误

Property 'send' does not exist on type 'Request<ParamsDictionary>' NodeJS

我进行了研究,发现这是TS问题,但问题是我没有在该项目中使用TS。

有什么建议吗?

这是我的package.json

 {
  "name": "postgres",
  "version": "1.0.0",
  "main": "app.js",
  "scripts": {
    "start": "node app.js",
    "dev": " nodemon app.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.19.0",
    "express": "^4.17.1",
    "express-handlebars": "^4.0.4",
    "pg": "^8.2.1",
    "pg-hstore": "^2.3.3",
    "sequelize": "^6.2.3"
  },
  "devDependencies": {
    "nodemon": "^2.0.4"
  },
  "description": ""
}

App.js

 const app = express();

app.get('/',(res,req)=>{
    res.send('Hello wolrd')
})

2 个答案:

答案 0 :(得分:1)

您只是把订单弄错了。是req, res而不是res, req

答案 1 :(得分:0)

您的错误是第一个arg是req,第二个res是

app.get("/", (req, res)=> {
res.send("hallo wolrd");
});