From a2339e42d1198e4796dca9719c833ff41bf642f7 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.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/api/vm.markdown b/doc/api/vm.markdown index bfe8109a30212d..4cccc12378631e 100644 --- a/doc/api/vm.markdown +++ b/doc/api/vm.markdown @@ -212,8 +212,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