From f17b9494e169f8a3a2744b17a407faa3a1c52800 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 14 May 2016 10:14:02 +0200 Subject: [PATCH] doc: update vm.runInDebugContext() example The debugger needs to be active now before one is allowed to query the list of scripts. Replace the example with one that works without installing a debug event listener first. Fixes: https://github.com/nodejs/node/issues/4862 PR-URL: https://github.com/nodejs/node/pull/6757 Reviewed-By: Colin Ihrig Reviewed-By: Myles Borins --- doc/api/vm.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/api/vm.md b/doc/api/vm.md index a128b39000385c..b212cc6e29327f 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -221,8 +221,10 @@ a separate process. context. The primary use case is to get access to the V8 debug object: ```js +const vm = require('vm'); const Debug = vm.runInDebugContext('Debug'); -Debug.scripts().forEach((script) => { console.log(script.name); }); +console.log(Debug.findScript(process.emit).name); // 'events.js' +console.log(Debug.findScript(process.exit).name); // 'internal/process.js' ``` Note that the debug context and object are intrinsically tied to V8's debugger