From 50f02bd8d63a99b76ffd622e65a271a948c5769b 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