markelog/eclectica

node.js — reapply global modules

Closed this issue · 4 comments

how about not ?

It to slow, error prone, or something like that?

1 slow and 2 I have errors
3 could it be optional ?

for example global modules could be installed from private registry
when reapplying you don't catch error and fail on installing specified node.js version
or another one - if I have no internet connection ( in flight for example) I could not switch node.js version =(

A little backstory.

There is two main version changer for nodejs right now – n and nvm.
Whereas n has common place for storing global modules between various node versions, which causes issues if you switching between very old and newer node versions i.e. – "0.10" to 6.x or something.

Modules that use gyp compilation will fail in such case.

By default nvm, on the other hand, will reinstall modules only with passed --reinstall-packages-from argument. And of course has separate global node_modules for each installed version. Nowadays they also support the default-packages feature too.

eclectica in this case, tries to reinstall global modules with recently added --offline flag (not yet even properly documented I believe) from the disk and make no network requests (at least in most cases).

Since --offline flag (same story with --prefer-offline arg too) was added only recently it might will not work on more older versions of node.

I was wondering if those two approached could be united in some way. Tried many different things – like installing with global modules with yarn or copy modules if eclectica switches between minor|patch versions and etc.

Given that current approach is not really stable and reinstall of global modules eventually (depends on how many modules we moving around) is slow, plus the fact that I don't do it for other supported languages.

I guess hiding this behaviour under the flag should indeed be the best course of actions