Advertisement
Justman10000

Manage NodeJS

Oct 11th, 2024 (edited)
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.83 KB | None | 0 0
  1. // To install
  2. version=$(curl -Ls https://nodejs.org/dist | grep -ioP 'v\d\d?\.\d\d?\.\d\d?' | sort -rV | head -n 1)
  3.  
  4. wget https://nodejs.org/dist/$version/node-$version-linux-x64.tar.xz
  5. unxz node-$version-linux-x64.tar.xz
  6. tar xvf node-$version-linux-x64.tar
  7. rm node-$version-linux-x64.tar
  8.  
  9. mkdir /usr/local/node
  10. mv node-$version-linux-x64 /usr/local/node/$version
  11. ln -fs /usr/local/node/$version/bin/* /usr/bin
  12.  
  13. # For Yarn
  14. corepack enable
  15. # For Bun (https://bun.sh)
  16. curl -fsSL https://bun.sh/install | bash
  17.  
  18. node -v
  19.  
  20. # To reregister standart Node version
  21. for bin in $(ls /usr/local/node/$version/bin); do
  22.     ln -fs /usr/local/node/$version/bin/$bin /usr/bin/$bin
  23. done
  24.  
  25. // To uninstall
  26. # Add $version for a specific version
  27. rm -r /usr/local/node
  28.  
  29. for bin in $(ls /usr/local/node/$version/bin); do
  30.     rm /usr/bin/$bin
  31. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement