Windows上的Node.js根在哪里?

这里是我的Node.js代码(试图console.log到一个文件):

var fs = require('fs'); var util = require('util'); var logFile = fs.createWriteStream('/tmp/test', { flags: 'a' }); // Or 'w' to truncate the file every time the process starts. var logStdout = process.stdout; console.log = function () { logFile.write(util.format.apply(null, arguments) + '\n'); logStdout.write(util.format.apply(null, arguments) + '\n'); } console.error = console.log; 

我的问题:我找不到这个神话/ tmp /testing文件夹。

该目录/tmp/test在Windows上不存在。 它只存在于Linux上。 将其replace为Windows上实际存在的path。 像C:/file.txt

在创build文件时,您可能需要检查权限和path。