Debug
vscode Debug
TIP
我们已经有了 lanch.json 文件,你只需要在 VS Code Run And Debug
中选择 Remix dev
启动服务即可。然后在打上断点,控制我们想要的断点。
json
{
// 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": "Remix dev",
"runtimeExecutable": "pnpm",
"runtimeArgs": ["run", "dev"]
}
]
}
使用 pnpm 运行 script 中的 dev 脚本, 等同于运行 pnpm run dev
。
Debug 模式
可以使用 debug
模式启动服务
sh
DEBUG=* pnpm run dev
会展示所有的 debug 信息,下面我们介绍自定义 debug 信息。需要先安装一个包:
sh
pnpm add debug -D
初始化一个类型的 debug
ts
const dataDebug = debug("data:debug")
使用
ts
const data = {x: {y: { z : 3 }}}
dataDebug(data)