asar
asar copied to clipboard
Failing with scoped node_modules
Asar seems to fail with modules that are scoped, e.g.. @scope/project-name
.
Getting the following error while asar is iterating over the node_modules/@pnpm/default-fetcher
directory:
/Users/dave/code/my-app/app/node_modules/asar/lib/filesystem.js:20
json = json.files[dir]
^
TypeError: Cannot read property 'files' of undefined
at Filesystem.searchNodeFromDirectory (/Users/dave/code/my-app/app/node_modules/asar/lib/filesystem.js:20:21)
at Filesystem.searchNodeFromPath (/Users/dave/code/my-app/app/node_modules/asar/lib/filesystem.js:30:23)
at Filesystem.insertDirectory (/Users/dave/code/my-app/app/node_modules/asar/lib/filesystem.js:41:23)
at handleFile (/Users/dave/code/my-app/app/node_modules/asar/lib/asar.js:120:20)
at next (/Users/dave/code/my-app/app/node_modules/asar/lib/asar.js:160:12)
at /Users/dave/code/my-app/app/node_modules/asar/lib/asar.js:161:14
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
I am not sure if this is the same issue, but I had a similar error message when trying it with the pattern
'/{electron.js,package.json,dist/**/*,node_modules/electron-log/**/*}'
My workaround after debugging this filesystem.js file was to change my pattern to include the parent dir before the subdir, like this:
'/{electron.js,package.json,dist/**/*,node_modules,node_modules/electron-log/**/*}'
I ran into the error when extracting a file this way:
$ asar ef ~/.cache/Cypress/3.4.1/Cypress/resources/electron.asar /browser/api/web-contents.js
In my case the fix was to strip the leading slash:
$ asar ef ~/.cache/Cypress/3.4.1/Cypress/resources/electron.asar browser/api/web-contents.js
Otherwise the first item in the list is empty.
Quick note:
I've been trying to migrate electron-builder to use the official electron/asar package, however, this issue is blocking me from properly packaging the asar with the current builder's flow.
I can pack all files and let asar
figure out what to unpack, but electron-builder also allows a unpack
string[] of regexes that I can't figure out how to handle using this asar
package. Files are moved/unpacked to app.asar.unpacked
folder, but asar
doesn't seem to provide that functionality. Any advice/help would be greatly appreciated
@davej this should be fixed in latest asar release