Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
89
rated 0 times [  94] [ 5]  / answers: 1 / hits: 14861  / 6 Years ago, wed, april 11, 2018, 12:00:00

I've understood that I'm using react.js version 15.6.2. I know this because doing this in my code:



console.log(React.version);


results in this console output:



15.6.2


I want to upgrade to React@^v16.2.0. I tried doing this:



sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo n latest


But nothing changes. I get the same version output in the console. How do I upgrade node?



EDIT:



Here's the situation, I'm in a project folder with the following hierarchy:



enter



node_modules seems to contain the react installation, since it has a react folder with a package.json file containing the version number 15.6.2.



I've tried both npm update --save react and npm update -g react. None worked. Same thing happens, and the same version number can be found in node_modules/react/package.json. I even tried to run npm install again before hosting with npm start. Any other suggestions?


More From » reactjs

 Answers
9

Use npm update --save react to update to latest version.
For a specific version use npm update --save [email protected].



React should not be installed globally but only for your project. If this is not the case use -g instead of --save



UPDATE



Okay my fault. Just use npm install --save [email protected]. This installs the new version.


[#14110] Tuesday, April 10, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
freddiejarretk

Total Points: 612
Total Questions: 103
Total Answers: 88

Location: Armenia
Member since Sat, Dec 31, 2022
1 Year ago
;