问题描述
在Ubuntu 20.01 LTM中尝试使用VS Code设置SDL2时,出现以下VS Code错误:
"/usr/include/SDL2/"
有什么提示吗?
解决方法
只需将{
"configurations": [
{
"name": "Linux","includePath": [
"${workspaceFolder}/**","/usr/include/SDL2/"
],"defines": [],"compilerPath": "/usr/bin/gcc","cStandard": "gnu18","cppStandard": "gnu++14","intelliSenseMode": "gcc-x64"
}
],"version": 4
}
添加到您的c_cpp_properties.json中,如下所示:
// Filename : user.js
const express = require("express");
const { check,validationResult} = require("express-validator");
const bcrypt = require("bcryptjs");
const jwt = require("jsonwebtoken");
const router = express.Router();
const User = require("../model/User");
/**
* @method - POST
* @param - /signup
* @description - User SignUp
*/
router.post(
"/signup",[
check("username","Please Enter a Valid Username")
.not()
.isEmpty(),check("email","Please enter a valid email").isEmail(),check("password","Please enter a valid password").isLength({
min: 6
})
],async (req,res) => {
const errors = validationResult(req);
console.log(errors);
if (!errors.isEmpty()) {
console.log("error sign");
return res.status(400).json({
errors: errors.array()
});
console.log("error sign2");
}
console.log("error sign3");
const {
username,email,password
} = req.body;
try {
let user = await User.findOne({
email
});
if (user) {
return res.status(400).json({
msg: "User Already Exists"
});
}
user = new User({
username,password
});
const salt = await bcrypt.genSalt(10);
user.password = await bcrypt.hash(password,salt);
await user.save();
const payload = {
user: {
id: user.id
}
};
jwt.sign(
payload,"randomString",{
expiresIn: 10000
},(err,token) => {
if (err) throw err;
res.status(200).json({
token
});
}
);
} catch (err) {
console.log(err.message);
res.status(500).send("Error in Saving");
}
}
);
module.exports = router;
,
如果你和我一样,在你的项目中没有 c_cpp_properties.json
文件,你可以通过在你的 settings.json
中添加以下行来解决它(在 VSCode 中,点击 Ctrl+Shift+P 并搜索打开设置(JSON)):
{
// ...
"C_Cpp.default.includePath": ["/usr/include/SDL2","${default}"],//...
}