-1

I have come across ReactJS and React Native. ReactJS is brilliant, super fast and works fine on Node v0.10. But, React Native needs v4.x as a prerequisite. So, when I run any react-native command, it fails and says Node 4 is required.

I have tried several times and many ways to update Node, but, have failed.

First followed Installation Instructions -

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash sudo apt-get install -y nodejs 

I ended up with the following message-

root@purvotara:/# apt-get install -y nodejs Reading package lists... Done Building dependency tree Reading state information... Done nodejs is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 

Then, there was Manual Installation way of installing.

add-apt-repository -y -r ppa:chris-lea/node.js rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - echo 'deb https://deb.nodesource.com/node/dists/trusty/Release main' > /etc/apt/sources.list.d/nodesource.list echo 'deb-src https://deb.nodesource.com/node/dists/trusty/Release main' > /etc/apt/sources.list.d/nodesource.list apt-get update apt-get install nodejs 

Still, ended up with -

nodejs is already the newest version. 

I tried to purge and auto-remove my current v0.10 node and tried to freshly install, not sure if its still picking the install from the cache, but, v0.10 got installed.

Also followed linoxide article on the same. A .configure and make install didn't seem to work as well.

What am I doing wrong? I am stuck for hours.

Went over several other links to resolve other issues(they are resolved now)-

Uninstalling node

Failed to fetch Trusty

9
  • So which version node --version is showing now? Commented Oct 28, 2015 at 5:17
  • It shows v0.10 when I do node -v Commented Oct 28, 2015 at 5:18
  • 2
    Have to tried installing different version using NVM? Commented Oct 28, 2015 at 5:18
  • When I execute the CURL command and run scripts, it fetches all content w.r.t 4.x, but, later, when I do an INSTALL, it says, its already upto date and version would be 0.10 Commented Oct 28, 2015 at 5:19
  • 2
    Actually you can install NVM and switch version of node anytime. This link may help you to download digitalocean.com/community/tutorials/… Commented Oct 28, 2015 at 5:28

3 Answers 3

2

Use n. npm install -g n then you can switch to any version of node using a command like this n v4.1.2 https://www.npmjs.com/package/n

n uses /usr/local/bin/node for n to work properly on debian based systems, create a symlink to point to this directory.

sudo ln -s /usr/local/bin/node /usr/bin/node 
Sign up to request clarification or add additional context in comments.

2 Comments

This looks interesting! I will try it out and update the post soon.
Still facing the same problem. I installed 4.2.1, but, v0.10 is being shown. Updated as a part of answer. Please have a look.
1

@Holger This was the result of using 'n'. I have added this as an answer, as I want to bring more clarity in the code and solution itself.

Still facing the same problem. I installed 4.2.1, but, v0.10 is being shown.

root@purvotara:/# n 4.2.1 install : node-v4.2.1 mkdir : /usr/local/n/versions/node/4.2.1 fetch : https://nodejs.org/dist/v4.2.1/node-v4.2.1-linux-x64.tar.gz installed : v4.2.1 root@purvotara:/# n root@purvotara:/# node -v v0.10.25 

I used NVM and the issue is solved.

2 Comments

mmmh, you might try to uninstall the original packages... sudo apt-get remove nodejs... i'm not sure it helps though
Yes. I will try it out! This 'n' looks clean. I will further investigate and get it working. Thanks for the help.
-2

You can Do it Two ways. First try second step It must work for you.

1 Uninstall First version and Reinstall Other one 4.1.2 is latest as per my knowledge.

2 Click Here Follow steps.

sudo apt-get update sudo apt-get install build-essential libssl-dev curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh source ~/.profile nvm ls-remote nvm install 4.*.* // Latest version choose here nvm use 4.*.* // Latest version also here node -v // Check your version 

4 Comments

I need node 4.x to be installed. Not Node 0.11. As I said earlier. I uninstalled node and reinstalled it. That is not giving the latest version.
when through command nvm ls-remote than list out latest version of node JS. You can pass nvm install 4.*.* & nvm use 4.*.*
As per my knowledge v4.2.1 is latest .
Yes. Thanks :) I updated to v4.2.1 and got it working.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.