Ich leite Knoten 22.9.0 auf einem Raspberry Pi (Linux RaspberryPI 6.1.21-V8+)
Mein Skript, das als Stamm ausgeführt wird, kann eine neue Datei im aktuellen Verzeichnis schreiben und diese Datei in Ordnung aktualisieren. < /p>
Code: Select all
total 332
drwxr-xr-x 11 root root 4096 Feb 8 06:37 .
drwxr-xr-x 4 root root 4096 Dec 20 07:24 ..
.....
-rw-r--r-- 1 root root 1861 Feb 8 06:37 database.json (THE FILE)
Code: Select all
Error! Error: EACCES: permission denied, open 'database.json'
Es scheint, dass ich in der Schleife den Zugriff auf das Verzeichnis verliere ...
Code: Select all
setInterval(() => {
console.log(process.env.USER) // root
fs.access("./database.json", fs.constants.W_OK, (err) => {
if (err) {
// am seeing this log!!
console.error('Directory is not writable');
}
});
}, 2000);