Skillpedia
برمجة عامة260k · #572

node-inspect-debugger

ما الذي تفعله

تساعد هذه المهارة وكيلك على إيجاد الأخطاء في برامج Node.js باستخدام المصحح المدمج في Node. وهي للمطورين الذين يحتاجون إلى رؤية حالة البرنامج أثناء إيقاف الشيفرة مؤقتًا.

متى تستخدمها

  • ✓عندما يفشل اختبار Node.js ولا تكشف طباعة القيم السبب.
  • ✓عندما يتصرف برنامج Node.js بشكل خاطئ وتحتاج إلى فحص القيم في حالة إيقاف مؤقت.
  • ✓عندما تحتاج إلى الاتصال بعملية Node قيد التشغيل لقياس سرعتها أو ذاكرتها.

رابط المهارة

https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/software-development/node-inspect-debugger/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/software-development/node-inspect-debugger/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“اختبار Node.js الخاص بي يفشل ويعطي مجموعًا خاطئًا، وconsole.log لا يفيد. هل تضع نقطة توقف وتعرض لي القيم؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

تشغّل المهارة Node بمفتشه المدمج، ثم تستخدم أمر node inspect أو سكربت DevTools لوضع نقاط التوقف والتنقل في الشيفرة وقراءة المتغيرات في الإطار المتوقف.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Node.js Inspect Debugger

Overview

When console.log isn't enough, drive Node's built-in V8 inspector programmatically from the terminal. You get real breakpoints, step in/over/out, call-stack walking, local/closure scope dumps, and arbitrary expression evaluation in the paused frame.

Two tools, pick one:

  • node inspect — built-in, zero install, CLI REPL. Best for quick poking.
  • ndb / CDP via chrome-remote-interface — scriptable from Node/Python; best when you want to automate many breakpoints, collect state across runs, or debug non-interactively from an agent loop.

Prefer node inspect first. It's always available and the REPL is fast.

When to Use

  • A Node test fails and you need to see intermediate state
  • ui-tui crashes or behaves wrong and you want to inspect React/Ink state pre-render
  • tui_gateway child processes (_SlashWorker, PTY bridge workers) misbehave
  • You need to inspect a value in a closure that console.log can't reach without patching
  • Perf: attach to a running process to capture a CPU profile or heap snapshot

Don't use for: things console.log solves in under a minute. Breakpoint-driven debugging is heavier; use it when the payoff is real.

Quick Reference: node inspect REPL

Launch paused on first line:

node inspect path/to/script.js
# or with tsx
node --inspect-brk $(which tsx) path/to/script.ts

The debug> prompt accepts:

Command Action
c or cont continue
n or next step over
s or step step into
o or out step out
pause pause running code
sb('file.js', 42) set breakpoint at file.js line 42
sb(42) set breakpoint at line 42 of current file
sb('functionName') break when function is called
cb('file.js', 42) clear breakpoint
breakpoints list all breakpoints
bt backtrace (call stack)
list(5) show 5 lines of source around current position
watch('expr') evaluate expr on every pause
watchers show watched expressions
repl drop into REPL in current scope (Ctrl+C to exit REPL)
exec expr evaluate expression once
restart restart script
kill kill the script
.exit quit debugger

In the repl sub-mode: type any JS expression, including access to locals/closure variables. Ctrl+C exits back to debug>.

Attaching to a Running Process

When the process is already running (e.g. a long-lived dev server or the TUI gateway):

# 1. Send SIGUSR1 to enable the inspector on an existing process
kill -SIGUSR1 <pid>
# Node prints: Debugger listening on ws://127.0.0.1:9229/<uuid>

# 2. Attach the debugger CLI
node inspect -p <pid>
# or by URL
node inspect ws://127.0.0.1:9229/<uuid>

To start a process with the inspector from the beginning:

node --inspect script.js           # listen on 127.0.0.1:9229, keep running
node --inspect-brk script.js       # listen AND pause on first line
node --inspect=0.0.0.0:9230 script.js   # custom host:port

For TypeScript via tsx:

node --inspect-brk --import tsx script.ts
# or older tsx
node --inspect-brk -r tsx/cjs script.ts

Programmatic CDP (scripting from terminal)

When you want to automate — set many breakpoints, capture scope state, script a repro — use chrome-remote-interface:

npm i -g chrome-remote-interface        # or project-local
# Start your target:
node --inspect-brk=9229 target.js &

Driver script (save as ~/.hermes/cache/scratch/cdp-debug.js):

const CDP = require('chrome-remote-interface');

(async () => {
  const client = await CDP({ port: 9229 });
  const { Debugger, Runtime } = client;

  Debugger.paused(async ({ callFrames, reason }) => {
    const top = callFrames[0];
    console.log(`PAUSED: ${reason} @ ${top.url}:${top.location.lineNumber + 1}`);

    // Walk scopes for locals
    for (const scope of top.scopeChain) {
      if (scope.type === 'local' || scope.type === 'closure') {
        const { result } = await Runtime.getProperties({
          objectId: scope.object.objectId,
          ownProperties: true,
        });
        for (const p of result) {
          console.log(`  ${scope.type}.${p.name} =`, p.value?.value ?? p.value?.description);
        }
      }
    }

    // Evaluate an expression in the paused frame
    const { result } = await Debugger.evaluateOnCallFrame({
      callFrameId: top.callFrameId,
      expression: 'typeof state !== "un
الأسئلة الشائعة

هل أحتاج إلى تثبيت شيء؟

لا للطريقة الأساسية. تقول المهارة إن node inspect مدمج، أما الخيار البرمجي فيحتاج إلى حزمة إضافية.

متى لا يستحق استخدامها؟

تقول المهارة تجاوزها حين يمكن حل المشكلة بـ console.log في أقل من دقيقة.

هل يمكنها تحليل تطبيق يعمل؟

نعم. تذكر المهارة الاتصال بعملية قيد التشغيل لالتقاط ملف تعريف لاستخدام المعالج أو لقطة للكومة (heap).

التفاصيل

الوصف الأصلي من المؤلف

Debug Node.js via --inspect + Chrome DevTools Protocol CLI.

repo: NousResearch/hermes-agent

الشعبية

نجوم GitHub
260k
الترتيب
#572
الترخيص
MIT
آخر تحديث
2‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة