Hi

I think I've done something of interest to others. It's a bit of a hack,
but I've been able to (from within the Windows VM) use npm link and keep
the node_modules inside the VM.

All I wanted to do is put links inside node_modules (links that actually
look like links to Windows, and not have npm complain about
node_modules/universal being a clone), and mklink doesn't work on any
network fs I've tried.

Here;s the thing:
- Make the vagrant shared directory read-only (optional, but it feels good).
- Create a directory in the VM: c:\gpii
- Create a link to each file/directory in the source root except for
node_modules. (in the VM I run links.bat[1] then rmdir node_modules)
- npm install, and node_modules is created in c:\gpii on the VM drive, and
everything else is loaded from the host (by following the symlinks).

So, it's similar to how c:\vagrant links to "everything" - but it links to
"almost everything".

This feels it should work, however when you decide to run gpii.js (which is
a symlink) it resolves to "\\vboxsvr\vagrant\gpii.js" and then everything
else becomes relative to that (including node_modules).

Fortunately, this resolving is just performed by fs.realpath/realpathSync
so after a quick hack to force everything in "\\vboxsvr\vagrant\" to really
resolve to "c:\gpii\" (adjust-links.js[2]), node now loads things from
c:\gpii leaving the OS to resolve it. You just have to add a --require
option to node:

gpii-windows: node --require adjust-links.js gpii.js
gpii-app: node_modules\electron\dist\electron.exe --require
c:\gpii\adjust-links.js main.js

I've been using this for a few weeks - forgot all about it until now (I
"re-provision" using snapshots).

Steve

[1] links.bat:
https://gist.github.com/stegru/ea0e1190bca2e02ec9255348a01232a2
[2] adjust-links.js:
https://gist.github.com/stegru/ec8eb3f9637e6f4d8c0619e8d0c54293
_______________________________________________
Architecture mailing list
[email protected]
http://lists.gpii.net/mailman/listinfo/architecture

Reply via email to