0
我正在尝试使用node.js读取本地文件。我的NPM模块正在尝试执行子进程,并且该进程打开要读取的文件。在阅读这篇引发错误读取node.js中的本地文件时出现错误
{ [Error: ENOENT, open 'E:\Project\SecIntegrator\Attack\manifest.json']
errno: 34,
code: 'ENOENT',
path: 'E:\\Project\\SecIntegrator\\Attack\\manifest.json' }
实际路径读取该文件是
E:\Project\SecIntegrator\node_modules\restScannerDriver\GarudRudra\Attack\manifest.json
我已经使用VAR configPath = path.join(path.dirname(fs.realpathSync(__filename)), '/');
计算绝对路径,但仍然没有工作。
您使用了用于读取方法的结果? – Bernhard
'file.readFile(fileName,'utf8',function(err,data){} – Gaurav
不确定,但你的路径看起来像一个Windows路径,所以看看这里http://stackoverflow.com/questions/10015877/node -js -fs-readfile-not-working-in-windows – Bernhard