Tag: 需要

从内存中的string加载node.js模块

如果我将文件的内容作为内存中的string,而不将它写出到磁盘,我将如何要求()一个文件? 这是一个例子: // 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) );