Node-fs-extra: move/remove fails in electron if directory contains .asar package

Created on 16 Oct 2018  路  7Comments  路  Source: jprichardson/node-fs-extra

  • Operating System: Windows 7 64bit / Ubuntu 18.04 64bit
  • Node.js version: electron 3.0.0
  • fs-extra version: 7.0.0

My application is NOT packed. I`m moving external folder that contains .asar package.
An error occurs, when you move a directory that contains an .asar package (for example electron.asar from electron dist):

fs.moveSync('d:\downloads\z', 'd:\downloads\z2')
14:03:27.334 D:\projects\atlas\launcher\node_modulesfs-extra\lib\copy-sync\copy-sync.js:177 Uncaught Error: Invalid package d:\downloads\z2\electron.asar
at invalidArchiveError (ELECTRON_ASAR.js:147)
at Object.fs.lstatSync (ELECTRON_ASAR.js:263)
at Object.fs.statSync (ELECTRON_ASAR.js:299)
at Object.statSync (D:\projects\atlas\launcher\node_modules\graceful-fs\polyfills.js:297)
at checkStats (D:\projects\atlas\launcher\node_modulesfs-extra\lib\copy-sync\copy-sync.js:174)
at checkPaths (D:\projects\atlas\launcher\node_modulesfs-extra\lib\copy-sync\copy-sync.js:183)
at copyDirItem (D:\projects\atlas\launcher\node_modulesfs-extra\lib\copy-sync\copy-sync.js:117)
at fs.readdirSync.forEach.item (D:\projects\atlas\launcher\node_modulesfs-extra\lib\copy-sync\copy-sync.js:111)
at Array.forEach ()
at copyDir (D:\projects\atlas\launcher\node_modulesfs-extra\lib\copy-sync\copy-sync.js:111)
at onDir (D:\projects\atlas\launcher\node_modulesfs-extra\lib\copy-sync\copy-sync.js:101)
at getStats (D:\projects\atlas\launcher\node_modulesfs-extra\lib\copy-sync\copy-sync.js:43)
at startCopy (D:\projects\atlas\launcher\node_modulesfs-extra\lib\copy-sync\copy-sync.js:36)
at copySync (D:\projects\atlas\launcher\node_modulesfs-extra\lib\copy-sync\copy-sync.js:31)
at tryCopySync (D:\projects\atlas\launcher\node_modulesfs-extra\lib\move-sync\index.js:97)
at moveDirSyncAcrossDevice (D:\projects\atlas\launcher\node_modulesfs-extra\lib\move-sync\index.js:93)
at moveSyncAcrossDevice (D:\projects\atlas\launcher\node_modulesfs-extra\lib\move-sync\index.js:56)
at tryRenameSync (D:\projects\atlas\launcher\node_modulesfs-extra\lib\move-sync\index.js:44)
at Object.moveSync (D:\projects\atlas\launcher\node_modulesfs-extra\lib\move-sync\index.js:22)
at :1:4

Another error occurs when you trying remove directory.

awaiting-reply feature-move feature-remove

Most helpful comment

Set process.noAsar = true may be work.

https://github.com/electron/electron/issues/9304

All 7 comments

Yeah, fs-extra is known to work a bit weird in electron sometimes, it seems electron's fs doesn't exactly mirror Node's. If someone can get to the bottom of this, that'd be great.

Set process.noAsar = true may be work.

https://github.com/electron/electron/issues/9304

not only move, copy is also not work.

The process.noAsar = true workaround seems to work. Not sure if there's a cleaner solution. Maybe fs-extra should always use original-fs if it exists?

May possibly be fixed by https://github.com/electron/electron/pull/23890; have not tested.

Is anyone still experiencing this issue with modern versions of fs-extra & electron?

Assuming this is fixed.

Was this page helpful?
0 / 5 - 0 ratings