Path too long issues on Windows
I am having problems on Windows when creating installers for our application. We have set asar = false for our builds but now we are getting Path too long errors. I have taken a look at the Electron App Packaging docs and they suggest that you can use a combination of app.asar and app.asar.unpacked.
The problem lies within our node_modules directory. I have files within my source that need to be unpacked but would like to have node_modules in an asar archive to avoid these errors. When I attempt to do this though my app is unable to find any modules.
Is my understanding of this method correct or am I just missing some steps here?
The require function in Electron should handle paths from both app.asar and app.asar.unpacked so node modules shouldn't run into issues when requiring files that are packed or unpacked.
It is common to have some files like .node files and other app.asar.unpacked but keep the bulk of the source files in app.asar.
When I attempt to do this though my app is unable to find any modules.
An example of the errors would be helpful to further diagnose your issue.
The require function in Electron should handle paths from both app.asar and app.asar.unpacked
This actually cleared up where my misunderstanding was. Using the require I am able to properly find the module. What I was trying to do was use the module directly by providing the path to its location, and since it was in the archive the path was not resolving.
Thanks for the response @kevinsawicki
Hi again @kevinsawicki,
We have tried using this method to unpack some of our modules but are now running into issues finding its dependencies. It is using the require function but doesn't seem to be searching within app.asar.
I have created a sample application that illustrates this, if you check the console tab in the debugger you can see it is failing to find dependencies. Any help on this issue would be great!
https://github.com/surajpindoria/electron-phonegap/blob/master/electron-phonegap-win32-x64.zip
@surajpindoria what error are you seeing?
It looks like your app is bundling/spawning node.exe, https://github.com/surajpindoria/electron-phonegap/blob/7303113727367f1fa55669202c8864d8993384fa/renderer.js#L8
Node doesn't support .asar files so you won't be able to require files from an .asar archive in there without using a module like https://github.com/electron/asar-require
This is the error we are seeing: Module error.pdf
So to use asar-require, do we need to add this on the Electron side or on the module side, in our case phonegap?
So to use asar-require, do we need to add this on the Electron side or on the module side, in our case phonegap?
On the module side
And then would we need to change all our require statements to look in the archive? As shown in the README for asar-require.
You should only need to add require('asar-require'); once before other files are required and then all others should just work without modifications.
I have tried this and can't seem to get it working. On Mac I am only able to require specific files using its path relative to the .asar (require('app.asar/node_modules/index.js')), not the whole module itself. Windows I can't do either.
Is this the intended behavior?
hi there.. if there is any issue about path too long I can suggest one best solution. try the Long Path Tool and it will make your life easier. thanks.