此命令應僅適用於新版的 Node。對於 Node v5 及更舊版本,請使用
sails debug
。
附加 Node 除錯器並啟動 Sails 應用程式 (類似於執行 node --inspect app.js
)。然後您可以使用像 Chrome DevTools 這樣的工具來互動式地除錯您的應用程式 (詳情請參閱 Node Inspector 文件)。
sails inspect
與 sails lift
採用相同的選項,請參閱此處列出的選項。
$ sails inspect
info: Running app in inspect mode...
info: In Google Chrome, go to chrome://inspect for interactive debugging.
info: For other options, see the link below.
info: ( to exit, type <CTRL>+<C> )
Debugger listening on ws://127.0.0.1:9229/7f984b04-b070-4497-bd15-056261a37f7c
For help see https://node.dev.org.tw/en/docs/inspector
若要將標準 (命令列) Node 除錯器與 Sails 搭配使用,您可以隨時執行
node inspect app.js
。
如果您在 Chrome DevTools 中沒有看到您的檔案,請嘗試點擊「Filesystem」標籤,並將您的專案資料夾新增到工作區。