diff --git a/doc/api/vm.md b/doc/api/vm.md index 9c81f7de71479f..2cc13631dbcc3a 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -919,6 +919,7 @@ const contextifiedObject = vm.createContext({ secret: 42 }); const module = new vm.SourceTextModule( 'Object.getPrototypeOf(import.meta.prop).secret = secret;', { + context: contextifiedObject, initializeImportMeta(meta) { // Note: this object is created in the top context. As such, // Object.getPrototypeOf(import.meta.prop) points to the @@ -937,7 +938,7 @@ await module.evaluate(); // To fix this problem, replace // meta.prop = {}; // above with -// meta.prop = vm.runInContext('{}', contextifiedObject); +// meta.prop = vm.runInContext('({})', contextifiedObject); ``` ```cjs @@ -947,6 +948,7 @@ const contextifiedObject = vm.createContext({ secret: 42 }); const module = new vm.SourceTextModule( 'Object.getPrototypeOf(import.meta.prop).secret = secret;', { + context: contextifiedObject, initializeImportMeta(meta) { // Note: this object is created in the top context. As such, // Object.getPrototypeOf(import.meta.prop) points to the @@ -964,7 +966,7 @@ const contextifiedObject = vm.createContext({ secret: 42 }); // To fix this problem, replace // meta.prop = {}; // above with - // meta.prop = vm.runInContext('{}', contextifiedObject); + // meta.prop = vm.runInContext('({})', contextifiedObject); })(); ```