Monday, 20 January 2020

Cross-platform "node_modules" directory

I'm developing an Electron app under macOS, and sometimes I need to jump into a Linux or Windows VM to write a fix there or something.How can I jump developing from different OS' very efficiently, possibly without the need for an internet connection for re-downloading all the dependencies (and avoiding the time required to do that)?So far I've encountered the following issues:When switching from macOS to Linux:The "electron" dependency needs to be re-downloaded because it itself downloads different files in its "postinstall" script depending on the host OS.Would just running npm i electron --force work for re-installing just that dependency?How could I make this work without an internet connection? Basically what would it take to write an "electron-universal" dependency that doesn't need to be reinstalled when switching OS'?When switching from macOS to Windows:I get lots of EPERM errors when trying to run the app.running sudo chown MY_USERNAME node_modules from Git Bash seems to work but it takes forever, is there a faster way? Maybe not all files need to be updated this way?Executables under node_modules/.bin are not found, how can I fix this?When switching back to macOS from Linux:Just reinstalling electron seems to work.When switching back to macOS from Windows:I haven't really tried to make it work without reinstalling all dependencies because I couldn't make it work under Windows in the first place without reinstalling all dependencies.Any tips on how to improve my situation and achieve a cross-platform node_modules?It's ok if I need to write some patching script for making "node_modules" work when switching OS, it should just not take forever and possibly work offline.If you want to reproduce my use case more closely try to make this project's "node_modules" cross platform.

Submitted January 21, 2020 at 02:01AM by fabiospampinato

No comments:

Post a Comment