-
-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node executable and libs seem to be duplicated #809
Comments
I guess one "workaround" is if we want to save disk with things as they are, we can use HOWEVER. the behavior of |
As you worked out, the downloaded versions are cached in So when you install 10 different versions of Node.js you end up with 11 copies. The active version and the 10 versions in the cache.
This is how Following on from my original example, when I get annoyed I have 11 copies of node because I installed 10 different versions, I can run It is ok to install a version of node and then immediately delete it from the cache, like:
|
Yeah I see that to get full storage efficiency we can |
What's even more confusing is this:
Installed node is v20
Clearly it's an uncommon use case as n is intended for rapid switching. But even the copying step if you switch between two cached versions takes nontrivial time because the executables and files are being actually copied around... somebody has to have an explanation for why we're doing all of these shenanigans when they could be done via changing symlinks. |
While I'm complaining about that. If you just
In all these scenarios 20 is already installed but it repeats all the work of copying it in anyway. |
I understand your desire to skip the install. I used to think that was a good idea too. The reinstall was a deliberate change in v5.0.0. The goal is a simple predictable behaviour. When you run The previous behaviour was it would not install if the active version matches. Great when things are working properly. The problem is if your active version is broken. I found myself suggesting people with problems do things like: n 8.0.0 # any version other than the one you actually want
n 20.0.0 # the one you actually want, and because it is changing versions it will actually reinstall |
|
@unphased, thank you for opening this issue. I'm working on adding @shadowspawn thank you for mentioning ENV NODE_VERSION=20
RUN curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s "${NODE_VERSION}" && \
npm install -g n && \
n rm "${NODE_VERSION}" && \
ln -sf "$(which node)" "$(which node)js" |
curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n -o /usr/local/bin/n
chmod a+x /usr/local/bin/n
n install "${NODE_VERSION}"
n rm "${NODE_VERSION}" The |
I would like to make it easier to install node with a single command without leaving behind a cache copy. Trying out some option names:
|
I was thinking about this again today, and like |
Bug Report
Summary and Repro
I set
$N_PREFIX
to~/.n
from my shell.n seems to install:
~/.n/n/versions/node/22.5.1/
(around 183MB)~/.n/bin
,~/.n/lib
,~/.n/include
,~/.n/share
:Expected Behaviour
Some sort of symlink from
~/.n/bin/node
to~/.n/n/versions/node/22.5.1/bin/node
and so on.If I install one node version it will consume 180-whatever MB disk.
If I install two node versions it will consume 360-whatever MB disk.
Actual Behaviour
If I install one node version it will consume 360-whatever MB disk.
If I install two node versions it will consume 550-whatever MB disk.
Other Information
I fully expect that there are various issues that have come up in the past that express some desire for
$N_PREFIX/bin/node
and friends NOT to be symlinks. However, I am not sure I buy that, because$N_PREFIX/bin/npm
is itself a symlink, to a "duplicated"$N_PREFIX/bin/../lib/node_modules/npm/bin/npm-cli.js
:Even if the 100+MB
node
executable has to get duplicated on disk why must we also do so forinclude/
andlib/
?The text was updated successfully, but these errors were encountered: