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.
Related
I can not run the Angular 2 project.
What I tried:
- running the project by using npm install and npm start | does not work
- I cloned quickstart from the github and replaced with my src folder and I still get the "can not find module in #angular/core"
Here is the full console output: https://www.dropbox.com/s/5plmqrjd6ge0lta/error.txt?dl=0
Many people will come here. I have had the same problem. Do not panic. You are probaly following the tutorial of tutorialspoint.
Just install the core again using NPM
npm install #angular/core
There was/is a bug in certain versions of npm that causes installed modules to disappear when using npm install someModule ... or npm install someModule --save-dev
This was apparently an issue if the module being installed was from a GitHub repo and lacked a specific commit hash to reference for the installation. Although the issue was marked "closed" and the repo archived several months ago at v5.6.0, I ran into the problem today w/the latest npm 6.4.0
In my case, doing npm install rxjs completely removed the #angular/core module, along with my #ionic-native plugins, and anything else I'd installed individually (and then it failed to actually/properly install rxjs anyway!!)
Tip: copy your existing npm modules folder as a backup before starting updates or removing it entirely & trying to npm install.
You can manually install to your project via npm install #angular/core, but depending on the npm version (or the angle of the moon at that precise moment, who knows) be aware that you might wind up with other missing dependencies.
Also try npm install #angular/core && npm install ... Apparently the additional npm install helps replace the randomly deleted/missing modules in some cases.
Using private npm, common commands seem not to work:
npm install without a specific #version :: issue
npm outdated :: issue
npm update :: issue
npm view <private-package-name> versions :: (haven't found issue yet)
also note that npm v, npm show, and npm info are aliases that likewise don't work
Frequently, I will not know the latest version of a private module my team maintains. I would fall back on one of the commands listed above, but they seem inoperative. How can I install a package without knowing the latest version?
If I understand your question, installing latest package would be:
npm install <package_name>#latest --save
According to the documentation, running npm install package-name is supposed to install the latest version the registry knows about. This may be different for private npm instances, but there doesn't appear to be so as they reference private repos in the documentation as well.
npm install [<#scope>/]<name>#<tag>:
Install the version of the package that is referenced by the specified
tag. If the tag does not exist in the registry data for that package,
then this will fail.
Example:
npm install sax#latest
npm install #myorg/mypackage#latest
From: https://docs.npmjs.com/cli/install on Nov 23, 2016
The solution I ultimately arrived at was to use the #* syntax when running the install:
npm install --save my-off_the_hook-module#*
This seems kind of sloppy to me but it does save the latest version of the module in a manner that is, so far as I can tell, equivalent to the more familiar (and my opinion more explicit) #latest syntax.
Don't know whether this is a missing feature or I'm doing something wrong but I have the following "problem".
Lets say I want to install the foo#3.2.x package and save it automatically in my package.json
npm install foo#3.2.x -S
This would write in my package.json the version ^3.2.0
npm install foo#3.2.x -SE
This would write in my package.json the version 3.2.0
What if I want to profit of the patch versions notation and I want to have the 3.2.x in my package.json?
The only option is adding it manually?
Thanks!
The semver shorthand ~ can be used to install only patch version updates of packages but not minor or major version updates (See https://docs.npmjs.com/misc/semver#tilde-ranges-123-12-1). To make this the default in npm use npm config command
npm config set save-prefix=~
Now the tilde will be used for every package installed with
npm install foo -S
And only patch level updates are installed when using npm i.
Is it possible to install multiple versions of npm for different projects that I am working on or are the npm installations always global? (Windows 10)
Are also tried installing different versions with https://github.com/marcelklehr/nodist but it seems to affect only the node version, not the npm version.
Or does npm version actually matter? Can I just use the newest npm version even when a project says the requirement is a certain npm version?
You can install multiple versions of npm by installing multiple versions of node. To do this, you can use nvm-windows. Each different installation of node installs a different version of npm
To use a different version of node and nvm in a project, you simple need to switch:
nvm use 5.0
You can also create a .nvmrc file containing the version number in the project root directory. nvm will use the specified version of node for that project.
You also can install npm using npm
Example of installing specific version:
npm i -g npm#3.5.4
If you need to use a different version of npm for each project, there are a number of possible solutions. Probably the lightest-weight version is to use npx. A semi-common use-case for this can be projects that use lock-file v1 and another that uses lock-file v2. v2 was introduced in npm v7.
So in your project using lockfile v1, if you need to install a new package.
npx npm#v6 install dalle-node
For lockfile v2, or to just use the latest and great.
npx npm#latest install dalle-node
Or does npm version actually matter?
In most cases, it's not likely to matter much. The above example is one I run in to in my own projects. If you use a project and some of the npm commands are giving you trouble, e.g. npm run, try using the version of npm the project recommends before filing a bug with the maintainer.
if you are using eclipse IDE for Node projects, you can easily change Node version using Webclipse plugin.
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.