nodejs服务端用的typescript该如何调试
发布于 6 年前 作者 cgstian 3820 次浏览 来自 问答

nodejs新手,该如何调试程序,我在程序中写了个debugger,不起作用

7 回复

上代码兄弟

换php吧,php才是最好的语言

// 可能是我的node版本问题,不用严格模式使用ES6语法会报错 import models from "./db" import express from “express” “use strict”; const router = express.Router();

/************** 创建(create) 读取(get) 更新(update) 删除(delete) **************/

// 创建账号接口 router.post(’/api/user/register’,(req,res) => { // 这里的req.body能够使用就在index.js中引入了const bodyParser = require(‘body-parser’) models.User.find({username: req.body.account}, (err,data) => { if (err) { debugger; console.log(err) // res.send(err); let newAccount = new models.User({ username : req.body.account, password : req.body.password }); // 保存数据newAccount数据进mongoDB newAccount.save((err,data) => { if (err) { res.send({‘status’: 1001, ‘message’: ‘Fail to register!’, ‘data’: err}); } else { res.send({‘status’: 1000, ‘message’: ‘Register successfully!’}); } }); } else { console.log(data) if (data.length > 0) { res.send({‘status’: 1001, ‘message’: ‘The account is already registered!’}); } else { let newAccount = new models.User({ account : req.body.account, password : req.body.password }); // 保存数据newAccount数据进mongoDB newAccount.save((err,data) => { if (err) { res.send({‘status’: 1001, ‘message’: ‘Fail to register!’, ‘data’: err}); } else { res.send({‘status’: 1000, ‘message’: ‘Register successfully!’}); } }); } } });

});

export default router;

我从网上下载的例子,将原来的js改成了ts,require换成了import,然后想看看程序一步一步怎么走的,但是不知道该如何进入断点

@zengming00 为什么PHP是最好的语言?请对比其他语言

Debugger listening on ws://127.0.0.1:14577/dc6df052-759d-42f8-b03f-3a61832bce6f (node:7108) [INSPECTOR_ASYNC_STACK_TRACES_NOT_AVAILABLE] Warning: Warning: Async stack traces in debugger are not available on 32bit platforms. The feature is disabled. warning.js:18 Mongo connection successed

这是什么情况,难道32位的vscode不能调试么?

回到顶部