-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
missing error.path at fs.mkdir callback on last call #28015
Comments
/ping @bcoe |
|
const fs = require('fs')
fs.writeFileSync('./text', '')
fs.mkdirSync('./text')
>node index2.js
internal/fs/utils.js:461
throw err;
^
Error: EEXIST: file already exists, mkdir './text'
?[90m at Object.mkdirSync (fs.js:748:3)?[39m
at Object.<anonymous> (C:\Users\himself65\Desktop\Github\test\index2.js:3:4)
?[90m at Module._compile (internal/modules/cjs/loader.js:774:30)?[39m
?[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)?[39m
?[90m at Module.load (internal/modules/cjs/loader.js:641:32)?[39m
?[90m at Function.Module._load (internal/modules/cjs/loader.js:556:12)?[39m
?[90m at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)?[39m
?[90m at internal/main/run_main_module.js:17:11?[39m {
errno: ?[33m-4075?[39m,
syscall: ?[32m'mkdir'?[39m,
code: ?[32m'EEXIST'?[39m,
path: ?[32m'./text'?[39m
} |
In the what's more, if we really create it, what's the happened in this example? const fs = require('fs')
fs.writeFileSync('./text', '')
fs.mkdirSync('./text')
// what will happened here???
fs.statSync('./text') In the |
Line 1402 in e8f3119
and when make dir loop call |
const fs = require('fs')
fs.writeFileSync('./foo', '')
try {
fs.mkdirSync('./foo/foo/foo', { recursive: true })
} catch (e) {
console.log(e)
console.log(e.path)
}
console.log('\n\n\n')
fs.mkdir('./foo/foo/foo', { recursive: true }, (e) => {
console.log(e)
console.log(e.path)
}) >node index2.js
Error: ENOTDIR: not a directory, mkdir './foo/foo/foo'
at Object.mkdirSync (fs.js:748:3)
at Object.<anonymous> (C:\Users\himself65\Desktop\Github\test\index2.js:4:6)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
at internal/main/run_main_module.js:17:11 {
errno: -4052,
syscall: 'mkdir',
code: 'ENOTDIR',
path: './foo/foo/foo'
}
./foo/foo/foo
[Error: ENOTDIR: not a directory, mkdir] {
errno: -4052,
code: 'ENOTDIR',
syscall: 'mkdir'
}
undefined
|
correct, but the issue is only about that path is missing in this error. I update the description. Sorry I should have written a better description. |
i get it. and I believe something escaped this line Line 1402 in e8f3119
|
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const file = path.join(__dirname, 'foo')
const dir = path.join(file, './foo/foo')
fs.writeFileSync(file, '')
fs.mkdir(dir, { recursive: true }, function (err) {
console.log(err)
})
fs.mkdir(dir, { recursive: false }, function (err) {
console.log(err)
})
fs.mkdir(dir, { recursive: false }, function (err) {
console.log(err)
})
fs.mkdir(dir, { recursive: false }, function (err) {
console.log(err)
})
fs.mkdir(dir, { recursive: false }, function (err) {
console.log(err)
}) C:\Users\himself65\Desktop\Github\test>node index2.js
[Error: ENOENT: no such file or directory, mkdir 'C:\Users\himself65\Desktop\Github\test\foo\foo\foo'] {
errno: -4058,
code: 'ENOENT',
syscall: 'mkdir',
path: 'C:\\Users\\himself65\\Desktop\\Github\\test\\foo\\foo\\foo'
}
[Error: ENOENT: no such file or directory, mkdir 'C:\Users\himself65\Desktop\Github\test\foo\foo\foo'] {
errno: -4058,
code: 'ENOENT',
syscall: 'mkdir',
path: 'C:\\Users\\himself65\\Desktop\\Github\\test\\foo\\foo\\foo'
}
[Error: ENOENT: no such file or directory, mkdir 'C:\Users\himself65\Desktop\Github\test\foo\foo\foo'] {
errno: -4058,
code: 'ENOENT',
syscall: 'mkdir',
path: 'C:\\Users\\himself65\\Desktop\\Github\\test\\foo\\foo\\foo'
}
[Error: ENOENT: no such file or directory, mkdir 'C:\Users\himself65\Desktop\Github\test\foo\foo\foo'] {
errno: -4058,
code: 'ENOENT',
syscall: 'mkdir',
path: 'C:\\Users\\himself65\\Desktop\\Github\\test\\foo\\foo\\foo'
}
[Error: ENOTDIR: not a directory, mkdir] {
errno: -4052,
code: 'ENOTDIR',
syscall: 'mkdir'
}
I think the actual bug is a missing path on last call |
so, this issue title should change to missing error.path at |
Expected to always have an Error with errno, code, syscall and path.
In the following 2 examples one error contains path and the other one doesn't.
I believe this was working with older node 10.x versions, possibly related to a change in #27198
Output:
The text was updated successfully, but these errors were encountered: