简体   繁体   English

节点文件系统 (fs.writeFile) 在 Meteor.js 中默认写入何处?

[英]Where does node file system (fs.writeFile) writes to on default in Meteor.js?

I am using the fs.writeFile method in the following way:我通过以下方式使用 fs.writeFile 方法:

        fs = require('fs');
        fs.writeFile('message.txt', 'Hello Node.js', (err) => {
            console.log('It\'s saved!');

            fs.readFile('message.txt', function (data) {

                console.log("Asynchronous read: " + data.toString());
            });
        });

output:输出:

It's saved!
Asynchronous read: Hello Node.js

Since I receive the expected output, I assume that the file message.txt is created somewhere, and I am actually writing and reading to/from it.因为我收到了预期的输出,所以我假设文件message.txt是在某处创建的,我实际上是在向它写入和读取它。 But I can not find it anywhere on my system.但是我在系统上的任何地方都找不到它。 So where is message.txt created?那么message.txt是在哪里创建的呢?

I am using Meteor.js我正在使用 Meteor.js

I found the file by using the command process.cwd() in my console.我通过在控制台中使用命令process.cwd()找到了该文件。

Since I am using Meteor.js, the file is saved on default to:由于我使用的是 Meteor.js,文件默认保存为:

../.meteor/local/build/programs/server

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM