0

I had node 6 before but I had to remove it to downgrade it to Node 4. But when I am trying to reinstall node 6/ install node 4, I am getting this error.

[root@vvvvvv xxxxxxx]# yum install -y nodejs
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
Package 2:nodejs-6.11.0-1nodesource.el7.centos.x86_64 already installed and latest version
Nothing to do

I used this to remove the previous version.

after this, as per another website source, I tried

sudo rm -fv /etc/yum.repos.d/nodesource*

but to no avail!!

When I am checking $node --version or $npm --version, I dont get any valid output.

aman_novice
  • 1,027
  • 3
  • 13
  • 31
  • `yum uninstall nodejs` didn't work to remove Node.js? The answer you linked in your question is related to uninstalling on OS X – Andrew Lively Jul 10 '17 at 16:40
  • @AndrewLively yeah i read on other websites too, it was the same for Linux(Cent OS in my case). yum uninstall works only for the packages installed using yum. I didnt install nodejs using yum – aman_novice Jul 10 '17 at 16:51
  • How did you install nodejs? Did you install it from source? Because in your first code example you are trying to install using `yum`. And what do you mean by "valid output" when calling `node --version`? – Andrew Lively Jul 10 '17 at 16:52
  • @AndrewLively : turns out, `yum erase nodejs` helped me remove the nodejs-6.11.0-1nodesource.el7.centos.x86_64. Thanks for that. Now incase I want to install node js 4, what is the way forward? I did `curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -` followed by `yum -y install nodejs` but it fails giving the error `https://rpm.nodesource.com/pub_4.x/el/7/x86_64/nodejs-6.11.0-1nodesource.el7.centos.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found` – aman_novice Jul 10 '17 at 17:01
  • 1
    The `setup_4` might not be available anymore, I would use the latest version and then see my answer below to change the version of Node once it is installed – Andrew Lively Jul 10 '17 at 17:10

1 Answers1

1

To install Node.js I would recommend using your package manager (yum):

yum install -y nodejs

Once you have nodejs and npm installed successfully on your machine, I would then use a Node version manager (I personally use n, but nvm works as well) to install a specific version:

npm install -g n

Then use your Node version manager to install a specific Node version:

n 4

NOTE: This command above will install the latest version of Node.js 4 (which at this time is 4.8.3). If you need a specific version you can specify it instead of just n 4. To see all available versions you can use the n ls command

You can verify your version of Node and npm using the --version flags as you were doing before

Andrew Lively
  • 2,145
  • 2
  • 20
  • 27
  • using `n` is giving me `mkdir: cannot create directory ‘/usr/local/n’: Read-only file system` which I understand will be an issue of the access and I can not go past it. I used nvm, and installed node 4.6.2. doing a `which node` gives me `/root/.nvm/versions/node/v4.6.2/bin/node` and `which npm` gives me `/root/.nvm/versions/node/v4.6.2/bin/npm` But when I am in another terminal, i get error, `-ksh: node: not found`. Path issue? – aman_novice Jul 10 '17 at 17:49
  • In my experience the `read-only file system` issue is something bigger related to your machine and not to Node. Usually when I have got that it is because of a panic with the system which locked up the file system and I fixed with a system restart. If you have a path issue you could create an alias in `/usr/bin` for node and npm to the `nvm` installed path – Andrew Lively Jul 10 '17 at 17:55