您的位置:首页 > 娱乐 > 明星 > 使用 devtool 本地调试 nodejs

使用 devtool 本地调试 nodejs

2024/7/6 19:00:12 来源:https://blog.csdn.net/u013243347/article/details/139906088  浏览:    关键词:使用 devtool 本地调试 nodejs

安装

# 全局安装
$ npm install devtool -g
# 或临时安装
$ npx devtool [file] [opts]

用法

Usage:devtool [入口文件] [opts]Options:--watch, -w             enable file watching (for development) # 动态检测文件变更,不用每次手动重启--quit, -q              quit application on fatal errors--console, -c           redirect console logs to terminal # 将日志打印到命令行--index, -i             specify a different index.html file--poll, -p              enable polling when --watch is given # 轮询--show, -s              show the browser window (default false) # 显示浏览器视窗--headless, -h          do not open the DevTools window # 不使用 devTools 调试窗口--timeout, -t           if specified, will close after X seconds # 超时时间--break                 insert a breakpoint in entry point # 断点调试--config                a path to .devtoolrc config file # 本地配置文件--verbose               verbose Chromium logging--version, -v           log versions of underlying tools--require, -r           require path(s) before running entry--browser-field, --bf   resolve using "browser" field--no-source-maps,--no-sm   disable source map generation--no-node-timers,--no-nt   use browser timers # 使用浏览器中的定时器--no-browser-globals,   --no-bg   removes window,document,navigator from required files

示例

调试一个本地的 index.js 文件

index.js

const test = 'test code';debuggerif(typeof test === 'string') console.log('string');if(typeof test === 'number') console.log('number')

调试上述文件

# 调试 index.js 并且会自动监听文件变更
$ npx devtool index.js -w

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com