Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update React npm package in Visual Studio 2017

I created a dotnet core 2.0 app using the React+ Redux template in VS2017. The template comes with react v15.6.1 by default, and I would like to upgrade this to v16.

I first tried going into the npm packages folder under the project dependencies list, and right clicking on react > Update Package. The update said it was completed but this however did not actually change my react version.

I then went into the package.json file and started typing in the new version and 16.2.0 came up as an intellisense option, but when I saved the file the package again did not update.

Has anyone figured out how to update the React version that comes with the template, there are a number of improvements in v16 I would like to make use of.

like image 715
Aleksandr Albert Avatar asked Dec 13 '17 08:12

Aleksandr Albert


People also ask

How do I update my react package?

To update your React version, install the latest versions of the react and react-dom packages by running npm install react@latest react-dom@latest . If you use create-react-app , also update the version of react-scripts . Copied! The command will update the versions of the react-related packages.

How do I download npm packages in Visual Studio?

js projects, the easiest way to install npm packages is through the npm package installation window. To access this window, right-click the npm node in the project and select Install New npm Packages. In this window you can search for a package, specify options, and install.

How do I update a reaction in an existing project?

To update an existing project to a new version of react-scripts , open the changelog, find the version you're currently on (check package. json in this folder if you're not sure), and apply the migration instructions for the newer versions. In most cases bumping the react-scripts version in package.


1 Answers

Here we go

After opening VS2017 go to

1) Tools -> NuGet Package Manager -> Package Manager Console

You will see Package Manager Console at the bottom pointing as PM>

2) Go to your root directory of main projects package.json file.

eg.

PM> cd D:\Myproject

3) Once you are in main directory type command below.

PM> ncu -u

After hitting this command, you will get notifications as below.

Using D:\Myproject\package.json

 @types/history                      4.6.0  →    4.6.2 
 @types/react                      15.0.35  →   16.3.8 
 @types/react-dom                   15.5.1  →   16.0.5 
 @types/react-hot-loader             3.0.3  →    3.0.6 
 @types/react-redux                 4.4.45  →   5.0.16 
 @types/react-router                4.0.12  →   4.0.23 
 @types/react-router-dom             4.0.5  →    4.2.6 
 @types/react-router-redux           5.0.3  →   5.0.13 
 @types/webpack                     2.2.15  →    4.1.3 
 @types/webpack-env                 1.13.0  →   1.13.5 
 awesome-typescript-loader           3.2.1  →    5.0.0 
 bootstrap                           3.3.7  →    4.1.0 
 css-loader                         0.28.4  →  0.28.11 
 event-source-polyfill               0.0.9  →   0.0.12 
 extract-text-webpack-plugin         2.1.2  →    3.0.2 
 file-loader                        0.11.2  →   1.1.11 
 history                             4.6.3  →    4.7.2 
 jquery                              3.2.1  →    3.3.1 
 react                              15.6.1  →   16.3.1 
 react-dom                          15.6.1  →   16.3.1 
 react-hot-loader             3.0.0-beta.7  →    4.0.1 
 react-redux                         5.0.5  →    5.0.7 
 react-router-dom                    4.1.1  →    4.2.2 
 redux                               3.7.1  →    3.7.2 
 style-loader                       0.18.2  →   0.20.3 
 typescript                          2.4.1  →    2.8.1 
 url-loader                          0.5.9  →    1.0.1 
 webpack                             2.5.1  →    4.5.0 
 webpack-hot-middleware             2.18.2  →   2.22.0 
 webpack-merge                       4.1.0  →    4.1.2 
 aspnet-webpack  ^2.0.1  →  ^2.0.3 

Upgraded D:\Myproject\package.json

If you still getting older versions

Then hit this commands

  1. npm install -g npm-check-updates
  2. ncu -u

Ref

like image 73
amar ghodke Avatar answered Oct 13 '22 16:10

amar ghodke