【发布时间】:2016-11-23 16:17:34
【问题描述】:
我正在尝试从虚拟文件系统加载一些节点模块 但我不能让它工作
var request = require('request')
, AdmZip = require('adm-zip')
, fs = require('fs')
, unionfs = require('unionfs')
, memfs = require('memfs')
, mem = new memfs.Volume
, data = []
unionfs.use(fs).use(mem)
unionfs.replace(fs)
var req = request({
method: 'GET',
uri: 'https://firebasestorage.googleapis.com/v0/b/****.appspot.com/o/node_modules.zip',
headers: {
"encoding": "binary"
}
})
req.on('data', function(chunk) {
data.push(chunk)
}).on('end', function() {
var binary = Buffer.concat(data)
mem.mountSync('./', {
"node_modules.zip": binary
})
var zip = new AdmZip("./node_modules.zip")
var files = {}
zip.getEntries().forEach(function(entry) {
if (entry.isDirectory)
console.log(entry.entryName)
files[entry.entryName] = entry.getData()
});
mem.mountSync('./node_modules', files)
//need to get these modules dynamically
var async = require("async")
})
我得到的错误是:错误:找不到模块'async'
现在我试图使用这个模块 https://www.npmjs.com/package/app-module-path 添加我的虚拟路径,但它只获取物理路径。
有人可以帮我解决这个请求吗?
不用担心安全性,我将对此使用加密。
【问题讨论】:
-
node.js的版本是什么? -
Node.js 是 v5.x,我在 0.14.7 版本中使用 NW.JS
-
将模块保存在文件系统中有什么问题?
-
这就是我现在使用系统上的临时文件夹所做的事情。我只是担心我的客户不允许我在某些极其安全的环境中写入此文件夹。
-
这是支持应用更新吗?如果是这样,可以更好地利用
node-webkit autoupdater吗?
标签: node.js filesystems node-modules virtualfilesystem