javascript - Node.js FileSystem access returns ENOENT despite the file existing -


i have node.js function uses fs.access check if file exists, readable , writable:

function stackoverflowfunction() { try {     fs.accesssync(`file://${__dirname}/config/config.ini`, fs.constants.f_ok | fs.constants.r_ok | fs.constants.w_ok); } catch (err) {     console.log(err); } 

despite file existing,

{ error: enoent: no such file or directory, access 'file:///home/callcenter1/bookgenerator/config/config.ini' @ error (native) @ object.fs.accesssync (fs.js:248:11) @ object.fs.accesssync (electron_asar.js:420:27) @ getconfig (/home/callcenter1/bookgenerator/main.js:12:12) @ object.<anonymous> (/home/callcenter1/bookgenerator/main.js:18:10) @ module._compile (module.js:541:32) @ object.module._extensions..js (module.js:550:10) @ module.load (module.js:458:32) @ trymoduleload (module.js:417:12) @ function.module._load (module.js:409:3) errno: -2,   code: 'enoent',   syscall: 'access',   path: 'file:///home/callcenter1/bookgenerator/config/config.ini' } 

i used "open link" function ubuntu terminal , opened file gedit successfully.

what's issue?

edit 1:

i'm sure path right:

enter image description here

use proper filesystem path, without scheme:

fs.accesssync(`${__dirname}/config/config.ini`, ...) 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -