Oliver Watkins
Oliver Watkins

Reputation: 13539

Why does "npm install react" install version 16 when latest version is 17?

If I run the command :

npm install react

I would expect it to install react 17 because apparantly version 17 is the latest version.

However after I run the comment, I see this in my package.json file

"react": "^16.14.0",

Am I missing something?

Upvotes: 1

Views: 1849

Answers (2)

Long Nguyen Duc
Long Nguyen Duc

Reputation: 1325

The installed version normally locked in package-lock.json (or yarn.lock if you're using yarn).

Npm/yarn will try with the locked version to avoid issues when deploy your code on production environment and the version conflict stuffs.

To upgrade your react version to latest version, please use the command as @jare25's mention.

npm install --save react@latest

Upvotes: 1

jare25
jare25

Reputation: 516

I think it installed it from your local npm, as for me your command installed 17.0.2.

For installing latest you should use:

npm install --save react@latest

Upvotes: 2

Related Questions