My package.json says I have react-router: 0.13.4 installed. However, when I type in the command npm view react-router it stats that it is using version: '1.0.0-rc3
I even tried npm install react-router#0.13.4 but npm view react-router still produces version 1.0.0-rc3
I believe npm view shows details of the latest remote package release, not the installed version. Look at node_modules/react-router/package.json to see your installed version. Use the npm install react-router#0.13.4 --save command if you want to update your package.json file.
npm install react-router-dom#5.3.0
then check the version in terminal with npm view react-router-dom#5.3.0 version
it will show the version of react router.
If you look at the react-router versioning on their GitHub releases page, you will notice there is no version 0.13.4 after version 0.13.3, which might be why NPM defaults to installing the latest version 1.0.0-rc3.
Related
I've tried updating npm after I did some WARNings, so I went
npm audit fix
received way more WARNs. Now when i tried installing all dependencies with
npm i
I got tons of WARN (see below). I honestly haven't got a clue what any of these mean, but did not have any before the npm fix.
Looks like you're using deprecated packages.
Try running
npm outdated
it will show you the current version, desired version, and latest version for each of your package. That won't actually do anything to your project, but it's a good first indication.
If you run
npm update
it will update each package according to what your package.json says.
For instance if you see this in your package.json
"my-package": "~1.25.0"
it means that npm update will update to (or that npm install will install) version 1.25.0 or the latest patch version such as 1.25.4.
If you see
"my-package": "^1.25.0"
it means that npm update will update to (or that npm install will install) version 1.25.0 or the latest minor or patch version such as 1.26.2.
However, npm update will not update your packages to new major versions. That means that "my-package" will not be update to 2.0.0 for instance.
I think using old version of packages can cause those kinds of warnings.
In that case, just reinstall the package to the latest version
npm uninstall my-package
npm i my-package
⚠️ But be careful as updating a package to a new major version could break your code!
My advice is to do it step by step and make sure you can always roll back in case there's a problem you don't understand!
I have an abandoned project which is the admin tool for a current project. This project's Material-UI version was 0.19.4. When I delete the dependency from package.json and run npm install, it installs the version "material-ui": "^0.20.2", Also when i edit my package.json, Material-UI's version by hand to version "^1.0.0" the npm crashes: No matching version found for material-ui#1.0.0. What am I missing? Why is the latest version not installed or at least the desired version? Can anyone guide me how to approach the issue?
Side note: When I run the project with the outdated Material-UI, it is not showing as the outdated version.
The newer components are now in #material-ui/core
see: https://material-ui.com/guides/migration-v0x/
npm install #material-ui/core
OR
yarn add #material-ui/core
There are some factors that may be causing the installation to fail. One that I know is maybe the version of npm is not the latest.
Try:
$ npm -g install npm
After that, try installing material-ui again.
That would work.
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:
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?
Use npm update --save react to update to latest version.
For a specific version use npm update --save react#16.2.0.
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 react#16.2.0. This installs the new version.
What version of package foo will this command install?
npm install foo#next
The package.json and semver docs don't mention next.
next is a version or tag published in your reference npm registry
npm install installs a package.
A package is:
...
d) a <name>#<version> that is published on the registry (see npm-registry) with (c)
e) a <name>#<tag> (see npm-dist-tag) that points to (d)
...
You can view the version that each dist-tag points to by running the following commands:
npm view <package_name> dist-tags
npm dist-tags ls <package_name>
e.g. for the react npm package:
npm view react dist-tags
Output:
{
latest: '17.0.2',
next: '18.0.0-rc.0-next-3dc41d8a2-20211223',
experimental: '0.0.0-experimental-3dc41d8a2-20211223',
beta: '18.0.0-beta-24dd07bd2-20211208',
rc: '18.0.0-rc.0'
}
Source
Next is tag. look at the below possible commands.
A tag can be used when installing packages as a reference to a version instead of using a specific version number:
npm install [<#scope>/]<name>
npm install [<#scope>/]<name>#<tag>
npm install [<#scope>/]<name>#<version>
npm install [<#scope>/]<name>#<version range>
How its added in package?
See dist-tag
npm dist-tag add <pkg>#<version> [<tag>]
npm dist-tag rm <pkg> <tag>
npm dist-tag ls [<pkg>]
Check - https://docs.npmjs.com/cli/dist-tag
Appending the #next tag to the package name installs the upcoming version, which is likely unstable.
From npm docs for npm-dist-tag:
Tags can be used to provide an alias instead of version numbers.
For example, a project might choose to have multiple streams of
development and use a different tag for each stream, e.g., stable,
beta, dev, canary.
By default, the latest tag is used by npm to identify the current
version of a package, and npm install (without any # or
# specifier) installs the latest tag. Typically, projects only
use the latest tag for stable release versions, and use other tags for
unstable versions such as prereleases.
The next tag is used by some projects to identify the upcoming
version.
Other than latest, no tag has any special significance to npm itself.
I'm on Ubuntu 14.04 trying to install this package: https://www.npmjs.com/package/stanford-corenlp
However, whenever I try to do so, it tries to install node-java 0.5.5 as a dependency which fails (gives me node-gyp errors).
I looked this issue up, and it's fixed by using a newer version of node-java. 0.6.1 seems to work fine, but I don't know how to update the dependency to install the stanford-corenlp package.
add
"node-java": "^0.6.1"
in 'dependencies' of your package.json file. Then run npm install. This will install the right version of node-java.
Then try to install standford-corenlp. If they didn't hardcode the node-java version in their package.json, you should be alright