Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the old version of node js?

I'm trying to install "n", the nom helper on Amazon Linux. I'm having difficulty. It seems I have an old version of the node somewhere but I can't figure out where. When I run

npm install -g n

I get the below error ...

[myuser@mymachine ~]$ sudo /usr/local/bin/npm install -g n
ERROR: npm is known not to run on Node.js v0.10.48
You'll need to upgrade to a newer version in order to use this
version of npm. Supported versions are 4, 6, 7, 8. You can find the
latest version at https://nodejs.org/
[myuser@mymachine ~]$ npm -v
5.4.2


   ╭─────────────────────────────────────╮
   │                                     │
   │   Update available 5.4.2 → 5.5.1    │
   │     Run npm i -g npm to update      │
   │                                     │
   ╰─────────────────────────────────────╯

But notice that when I run

[myuser@mymachine ~]$ node -v
v8.8.1

it tells me I have v8.8.1 installed, which is what I intended. How do I purge the old, unwanted version of the node so I can install my helper?

like image 599
Dave Avatar asked Oct 28 '25 15:10

Dave


1 Answers

Easiest solution would be to try the following to cleanup your node issues and reinstall a clean version.

First remove everything related to node

sudo apt-get purge --auto-remove nodejs npm

UPDATE For yum:

yum clean all
yum -y remove nodejs

Remove these leftover files and folders as well

sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules 

Then install node back with nvm,

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash

//To uninstall a node version 
//nvm uninstall <current version>

nvm install 8.8.1

nvm use 8.8.1

//check with 
node -v
npm -v


//**UPDATE**: Install your package
npm install -g n

And all should work.

UPDATE : Install Without NVM

yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_8.x | sudo -E bash -

yum install nodejs
node -v

//Install your package
npm install -g n
like image 108
Kalana Demel Avatar answered Oct 31 '25 05:10

Kalana Demel