vscode之调试js

使用vscode 可以直接对js文件进行调试,好强大。今天试了一把,很爽。

首先安装vscode

然后直接写一段js文件:

然后F5调试,选择nodejs

会有个配置文件,我是这么配置的:

如果想调试当前的文件,使用这个配置即可。

 {
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${file}",
            "sourceMaps": true
        }
    ]
}

 配置就绪之后,一直出错,提示

cannot find runtime ‘node’ on path

后来想想,可能是nodejs没有安装导致,

又去nodejs官网下载安装包:

安装完之后,居然还是不行,奇怪了。。。。。。

过了好久,我重启了一下vscode,然后居然好了。可以在控制台输出结果,也可以debug调试。

 另外,推荐一个插件,可以直接选择代码,然后执行,输出结果,对于开发来说,也是一件很舒服的事情。

 

运行之后,在output输出结果如下:

至此,使用vscode调试js完成测试。

猜你喜欢

转载自blog.csdn.net/g0415shenw/article/details/84894719