fs.unlinkSync throws "operation not permitted" error, but then works anyway

Viewed 592

This line of code

fs.unlinkSync("core.asar")

throws this error:

internal/fs/utils.js:269
    throw err;
    ^

Error: EPERM: operation not permitted, unlink 'core'
    at Object.unlinkSync (fs.js:1136:3)
    at Object.<anonymous> (D:\code\discord-tweaks\tools\inject.js:28:4)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -4048,
  syscall: 'unlink',
  code: 'EPERM',
  path: 'core'
}

but here's the fun bit, the file actually does get deleted. What on earth is going on here?

0 Answers
Related