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

Feature suggestion: n uninstall #540

Closed
shadowspawn opened this issue Dec 3, 2018 · 5 comments
Closed

Feature suggestion: n uninstall #540

shadowspawn opened this issue Dec 3, 2018 · 5 comments

Comments

@shadowspawn
Copy link
Collaborator

shadowspawn commented Dec 3, 2018

Suggestion

I propose n uninstall removes the active version of node and npm installed by n. e.g. for default install location:

  • rm -f /usr/local/bin/node
  • rm -f /usr/local/bin/npm
  • rm -f /usr/local/bin/npx
  • et al

I think this would be useful in various scenarios:

  • temporarily reverting to a system install of node (assuming one exists)
  • deleting node and npm because no longer using
  • cleaning out n installed node and npm because trying another way of managing them
  • cleaning out node and npm because broken, before trying a different install

History

This has come up multiple times. See #127 #169 PR #173 #238 #327 #441 #486

Three different things often get discussed or mixed together: uninstalling n, uninstalling the active version of node, and deleting the downloaded cached versions of node. I am suggesting n uninstall only does the middle case as they are useful separate operations and there are already simple commands for doing the other two flavours:

  • uninstall n: e.g. npm uninstall -g n
  • remove cached downloaded versions: e.g. n prune (all but one) or rm -rf /usr/local/n(all)

On a related note, the third party installer n-install has n-uninstall which does all three uninstall cases at once.

Other syntax considered, but I didn't like as much as uninstall:

Uninstall References and Implementation

Personally I initially didn't like the idea of implementing this because n installs using the nodejs distribution and does not use much specific knowledge of the layout. But it is a commonly requested feature, and it is a bit of a pain to delete manually. Two example links are:

I propose the implementation should use fixed knowledge of the target locations rather than consult a particular cached version, not least because you are likely to have installed multiple versions over time, and may have deleted the cached version.

I propose the implementation only deletes the files and folders n may have installed, and not other related things like global npm and node modules. I think just undoing the things that n was used for is simpler and safer.

@shadowspawn
Copy link
Collaborator Author

Proposed uninstall steps for default install to /usr/local:

rm -f "/usr/local/bin/node"
rm -f "/usr/local/bin/npm"
rm -f "/usr/local/bin/npx"
rm -rf "/usr/local/include/node"
rm -rf  "/usr/local/lib/dtrace/node.d"
rm -rf "/usr/local/lib/node_modules/npm"
rm -rf "/usr/local/share/doc/node"
rm -rf "/usr/local/share/man/man1/node.1"
rm -rf "/usr/local/share/systemtap/tapset/node.stp"

@FranklinYu
Copy link

How about /usr/local/n/?

@shadowspawn
Copy link
Collaborator Author

shadowspawn commented Apr 15, 2019

@FranklinYu
Thanks. I deliberately left that out. See the History section in my first comment. (I have fixed a typo where I referred to /usr/local/nvh/ instead of /usr/local/n/.)

@FranklinYu
Copy link

The typo was why I asked. Nevertheless, rm -rf /usr/local/n isn’t a simple command. It is only as simple as any command in your proposal.

@shadowspawn
Copy link
Collaborator Author

Added in v4.1.0

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

2 participants