In my package.json
file I have specified the react version as "react": "^16.13.1"
I then run npm install
to install the dependencies, however when I run npm run start
the project is built with the react version of my terminal, instead of the version specified in the package.json file.
Running npm view react version
returns 17.0.2
which is what npm uses to build the project, even though package.json specifies 16.13.1.
How can I force the terminal to use the specified version of react, or how do I downgrade to v16 in the terminal?
I am using Git Bash in Windows 10.
CodePudding user response:
You're using the wrong command.
npm view react version
shows you the latest version of React that is available to install. If you want to see what version you have currently installed, use npm ls react
.
CodePudding user response:
Turns out the issue was react was installed globally, so there were conflicting versions. Uninstalled with npm uninstall -g react
and the problem went away.
Also, thanks everyone for pointing out that npm view react version
returns the latest available version instead of the currently installed one.