Laden Sie das node.js-Modul aus der Zeichenfolge im Speicher

Wie würde ich eine Datei benötigen (), wenn ich den Inhalt der Datei als Zeichenfolge im Speicher hätte, ohne ihn auf die Festplatte zu schreiben? Hier ist ein Beispiel:

// Load the file as a string
var strFileContents = fs.readFileSync( "./myUnalteredModule.js", 'utf8' );

// Do some stuff to the files contents
strFileContents[532] = '6';

// Load it as a node module (how would I do this?)
var loadedModule = require( doMagic(strFileContents) );

Antworten auf die Frage(6)

Ihre Antwort auf die Frage