fs.mkdir, fs.mkdtemp(Sync) return ENOENT for the documentation example (Windows, run from git bash)
- Version: v8.4.0
- Platform: Windows 10
- Subsystem: git for Windows bash
The problem does not occur when node is started from a Windows shell - so it may be a git bash bug in the end?
Originally reported as flow-upgrade issue: facebook/flow#4647 (comment)
Code taken from https://nodejs.org/dist/latest-v8.x/docs/api/fs.html#fs_fs_mkdtemp_prefix_options_callback
fs.mkdtemp('/tmp/foo-', (err, folder) => { if (err) throw err; console.log(folder); // Prints: /tmp/foo-itXde2 });
When I run this from the node console started in the git for Windows bash I get
> fs.mkdtemp('/tmp/foo-', (err, folder) => {
... if (err) throw err;
... console.log(folder);
... // Prints: /tmp/foo-itXde2
... });
undefined
> Error: ENOENT: no such file or directory, mkdtemp '/tmp/foo-XXXXXX'
/tmp exists and is accessible and writable, I can run mkdir /tmp/foo _from the bash command line.
The problem becomes visible in the full error message:
> { Error: ENOENT: no such file or directory, mkdir 'C:\tmp\FOO'
errno: -4058,
code: 'ENOENT',
syscall: 'mkdir',
path: 'C:\\tmp\\FOO' }
Highlight: path: 'C:\\tmp\\FOO'