asar icon indicating copy to clipboard operation
asar copied to clipboard

Path too long issues on Windows

Open surajpindoria opened this issue 9 years ago • 10 comments

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?

surajpindoria avatar Sep 16 '16 21:09 surajpindoria

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.

kevinsawicki avatar Sep 19 '16 23:09 kevinsawicki

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

surajpindoria avatar Sep 20 '16 16:09 surajpindoria

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 avatar Sep 27 '16 23:09 surajpindoria

@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

kevinsawicki avatar Sep 27 '16 23:09 kevinsawicki

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?

surajpindoria avatar Sep 28 '16 18:09 surajpindoria

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

kevinsawicki avatar Sep 28 '16 18:09 kevinsawicki

And then would we need to change all our require statements to look in the archive? As shown in the README for asar-require.

surajpindoria avatar Sep 28 '16 18:09 surajpindoria

You should only need to add require('asar-require'); once before other files are required and then all others should just work without modifications.

kevinsawicki avatar Sep 28 '16 18:09 kevinsawicki

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?

surajpindoria avatar Sep 29 '16 21:09 surajpindoria

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.

whench18 avatar Apr 16 '17 02:04 whench18