2
在Node.js的,我试图写入到用户(在MacOS)的Documents
文件夹:在macOS上写入Node.js中的〜/ Documents文件夹?
var logger = fs.createWriteStream('~/Documents/somefolderwhichexists/'+title+'.txt');
这给了我一个错误,但我不知道什么是错的。错误说:
Uncaught Exception: Error: ENOENT: no such file or directory
我怎么能在这里使用绝对路径?或者我的错误是什么?
完美!非常感谢。 –
@GeorgeWelder我提供了一个更好的选择,以平台不可知的方式获取用户主目录。请尝试此以及当你有机会:) –