Skip to content
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

n fails when there is no internet access and other semi-related issues #404

Closed
sine9 opened this issue Jan 6, 2017 · 2 comments
Closed

Comments

@sine9
Copy link

sine9 commented Jan 6, 2017

Hello n developers! I love n and use it to quickly switch versions of node for testing.

I was on a plane recently no internet access and n stopped working. After seeing that you needed to specify the exact version number, I attempted to write a shell script wrapper and found other issues worth noting. They are all listed here:

  1. there seems to be no way to tell n to use the latest available for a given semver description if internet access is not available. To test this, try turning off your internet and running
$ sudo n 7
$ sudo n 7.
$ sudo n 7.x

All of these fail. The only thing that worked was running n and pulling the exact version number.

  1. a version number with an asterisk fails with some cp errors:
$ sudo n 7.*.*
cp: /usr/local/n/versions/node/7.*.*/bin: No such file or directory
cp: /usr/local/n/versions/node/7.*.*/lib: No such file or directory
cp: /usr/local/n/versions/node/7.*.*/include: No such file or directory
cp: /usr/local/n/versions/node/7.*.*/share: No such file or directory

n probably should just fail rather than attempt a command.

  1. n ls gives blank input when there is no internet connection. I can understand why, since "available" is determined by comparing against a list that is unavailable when internet is off, but since n can switch between installed versions n ls should show only the installed versions when internet access is not available.

  2. There is no command to just get a plaintext list of the installed versions. n is an interactive tool, redirecting to file or pipe screws with the shell session. n ls shows in bold but it's difficult to work with that programmatically. Some TTY detection logic may be necessary.

  3. the n list sorts the 0.10 and 0.12 series before the 0.8 series. That seems to be a bug that will rear its ugly head again if 6.10 is reached.

  4. How do I remove all older minor or patch versions of node? For example, my computer has a bunch of older node versions and I would like to prune to the latest patch version of the given major version:

    node/0.8.28

    node/0.9.12

    node/0.10.46 <-- remove
    node/0.10.47 <-- remove
    node/0.10.48

    node/0.11.16

    node/0.12.15 <-- remove
    node/0.12.16 <-- remove
    node/0.12.17 <-- remove
    node/0.12.18

    node/4.5.0 <-- remove
    node/4.6.0 <-- remove
    node/4.6.2 <-- remove
    node/4.7.0 <-- remove
    node/4.7.1

    node/5.12.0

    node/6.1.0 <-- remove
    node/6.8.0 <-- remove
    node/6.9.1 <-- remove
    node/6.9.2 <-- remove
    node/6.9.3 <-- remove
    node/6.9.4

    node/7.0.0 <-- remove
    node/7.2.1 <-- remove
    node/7.3.0 <-- remove
  ο node/7.4.0
@troy0820
Copy link
Collaborator

n prune will remove old versions of node on your system as of n 2.1.6

@shadowspawn
Copy link
Collaborator

shadowspawn commented Aug 25, 2019

There were a lot of interesting comments here, thanks @sine9.

I came across this issue again, so a status update for future readers.

  1. offline: no change (I think of the menu as a good option for offline)
  2. 7.*.*: now considered invalid
  3. listing: n ls now lists local versions
  4. plain text: n ls displays plain text
  5. sorting: fixed (and did eventually cause problems before it was fixed!)
  6. major version prune: no change, came up again in Feature: "n upgrade" for upgrading major versions #568

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants