New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why NodeJS fs module won't read or write to visible folder shared on the network? #4390
Comments
@nodejs/platform-windows does Node.js support network drives? |
Someone on StackOverflow suggested to use a package called node-cmd to update the credentials first and then use the fs function but it still fails for me : |
Did you try escaping backslashes |
You cant use a smb/cifs share as path in node.js. |
Does node support nfs/linux network shares? No. |
Does Node.js not support UNC paths on Windows? I was under the impression that any UNC path referring to a real file system (not an emulated file system or USB device or so) would work. |
Details
I shared a folder on my network through the use of Windows UI.
I'm able to access this folder and edit its content through the File Explorer but problems arise when I try to do the same programmatically. Any fs functions will work on the hoster machine but on any secondary device it won't.
I had to pass the hoster session credentials when I first tried to access the folder from the secondary device so I'm guessing this folder is invisible to NodeJS for the same reason but I'm not sure, and if so I don't know how to pass credentials to NodeJS to make network folders accessible to it.
Node.js version
20.12.0
Example code
node:fs:2342
return binding.writeFileUtf8(
^
Error: UNKNOWN: unknown error, open '//DESKTOP-NAME/folder/test.txt'
at Object.writeFileSync (node:fs:2342:20)
at file:///C:/Users/me/some_folder/some_file.js:3:4
at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12) {
errno: -4094,
code: 'UNKNOWN',
syscall: 'open',
path: '\\DESKTOP-NAME\folder\test.txt'
}
Node.js v20.12.0
Operating system
Microsoft Windows [Version 10.0.19045.4291]
Scope
code
Module and version
fs
The text was updated successfully, but these errors were encountered: