Does package.json "latest" versions include beta? - javascript

In package.json you can specify a package to be synced with the latest version:
{
...,
"devDependencies": {
"gulp": "latest",
...
},
...
}
Does "latest" include the alpha or beta versions, or just the latest stable version? I couldn't find definitive documentation on this.

The maintainers get to set the 'latest' tag to whatever they want. To wit:
#mac:~/projects/client$ npm outdated
Package Current Wanted Latest Location
bourbon 4.2.6 4.2.6 5.0.0-beta.2
webpack 2.1.0-beta.4 2.1.0-beta.4 1.12.14
'Latest' is set to the beta on bourbon, but webpack still has the stable as 'latest'.
There's also a tag 'next' that some maintainers use for prerelease version.

By default, NPM dependencies are pulled from the NPM repository. Authors must manually upload new versions of their software to the NPM repository, so the "#latest" version of the code hosted on NPM is different from the latest version of the code that exists anywhere (e.g., on GitHub).
According to the NPM repository's info page on Sails, the latest NPM-hosted version is 0.9.16 while the current GitHub version is 0.10.0-rc3.

Related

npm not installed latest version of package even after using caret(^)

I have added a package(X) as follows in package.json file
package(X): "^5.0.0"
now the latest version of package(X) is 5.0.1. According to my understanding this should install 5.0.1 but it installs version 5.0.0 itself.
Now I have multiple angular projects which are using package(X) and each of them have the same setup. What surprises me is that it works absolutely fine i.e installs version 5.0.1 in some projects and does not in some projects
Here is the info about package(x)
npm library info
It does depend on other packages' dependencies.
If there is a package that requires X to be exactly 5.0.0, then it will install 5.0.0 as it will satisfy ^5.0.0.
If there isn't one, then it will install whichever latest that will satisfy ^5.0.0 which is 5.0.1 in this case.

What happens when there are multiple versions available in organisation npm

I am fairly new to versioning a library, I wanted to get a clarity on my concern and please explain how does npm work.
I am trying to build a library and publish it to my organization npm registry. Now I have an alpha release which is already available in nexus and I did an npm install and the library works fine.
Now I when I create a stable release and make the library available for my organisation to use, when this happens the version tag will be updated to v1.0.0 and when I do an npm install the latest stable version will be available.
Post this, if I create further more alpha builds the version now has an alpha build tag appended to the version. Now when I do an npm install in a fresh project setup which version will I get:
stable version
new alpha version
I am a new to this, if anyone can explain how npm install will work and what version will I get that will be super helpful.
Thanks
What npm i will do for you, depends on what you stated in package.json.
{
"dependencies":{
"foo":"1.0.0", //match version exactly
"baz":">1.0.2", //must be greater than version
"elf":"~1.2.3", //everything from 1.2.3 to <1.3.0
"thr":"^1.2.3", //from 1.2.3 to <2.0.0
}
}
More details here
If you want to know the exact version of the package installed after npm i you could look it up in package-lock.json

How to install latest STABLE version of a Javascript package via a package manager?

How to install latest stable version of a Javascript package via a package manager?
(no alphas, betas, etc.)
I tried NPM and did not find a solution. This question is similar.
I tried Bower and find nothing. Here is a question with no answer here.
Please help. Which package manager should I choose? Maybe there are another options around?
PS
For example: knockout.js, npm givers beta for latest. I don't want beta! I also would like to set the same limitation for dependencies - pull only stable versions.
Installing a package without specifying a version will always install the latest version published to npm, including pre-releases (alpha, beta etc.):
npm install knockout
However, if you specify the version range, even only as a wildcard *, pre-release versions are explicitly excluded:
npm install knockout#*
See the npm docs for more info. Also, you can test this in npm's semver calculator.

Can I add a git repository to my bower.json? [duplicate]

I have a very small repo in which I do all dev work in the master branch and use tags as "stable" points in history.
I guess by default Bower seems to fetch the latest tagged version of a repo. I'm trying to get the most recent commit in the master branch.
I've tried running all these, in every conceivable order:
bower cache-clean mypackage
bower install mypackage --force-latest
bower install mypackage --force --force-latest
bower install mypackage --force
I've also tried adding latest to my bower.json file:
"dependencies": {
"mypackage": "latest"
}
And then running:
bower update mypackage
No matter what it seems to always get the latest tagged state.
How do I get the latest, most up-to-date, untagged state of the project?
Specify a git commit SHA instead of a version:
bower install '<git-url>#<git-commit-sha>'
Example:
bower install 'git://github.com/yeoman/stringify-object.git#d2895fb97d'
You can also specify a branch instead of a SHA, but that's generally not recommended unless it's in development and you control all the parts.
Yes, you can point to the git url, or use name/repo shorthand (for github repos):
bower.json
{
"name": "bower-test",
"dependencies": {
"dpm": "git#github.com:okfn/dpm.git",
"docker-nmpjs": "terinjokes/docker-npmjs"
}
}
More in the docs
As #roi noted in the comments, you can use the --save flag to automatically add dependencies to bower.json, e.g. bower install terinjokes/docker-npmjs --save
You can install a branch in Bower > 1.0.0:
bower install xxx#foo-branch
More details at https://github.com/bower/bower/issues/107#issuecomment-22352689.
If you are using a bower.json file you specify the latest version of a branch with a line in either the dependencies or devDependencies as appropriate for your project configuration:
"angular-bootstrap": "git#github.com:angular-ui/bootstrap.git#bootstrap3",
Then when you run bower install the latest version of that branch is installed. That would be branch bootstrap3 of angular-ui in this example.
bower install --save package-name#master
adds this:
"dependencies": {
"package-name": "master"
}
using bower.json:
"dependencies": {
"jquery.slimscroll": "latest",
"jQuery": "1.11",
"fullPage.js": "git#github.com:overbyte/fullPage.js.git#1d6bbac3d4c3b1d3d7d4096cdbcabd1c3914393f",
}
where
"[library name - in this case a forked version of fullpage.js]" : "[from git clone box in github][#commit number if required - without this you will get latest tagged version]"

npm git repository not updating versions

I have an git repo and I'm trying to set it as a dependency in my project.
Using NPM, my package.json looks like this:
"devDependencies": {
"grunt": "~0.4.0",
"grunt-contrib-connect": "~0.2.0",
"grunt-contrib-watch": "~0.3.1",
"custom": "git://github.com/myGitHubRepo/repo.js.git#b7d53a0cfbe496ad89bde6f22324219d098dedb3",
"grunt-contrib-copy": "~0.4.0"
}
On the first
npm install
It install everything and fetches the repository with no problem. But if I change this commit hash to let's say
"custom": "git://github.com/myGitHubRepo/repo.js.git#d6da3a0...", // a different one
It doesn't update! Can anyone point me out how could I get this behavior?
I would simply like to share this code and be able to at some point change this version and the npm would automatically update this.
Ok this is how it is done.
I was also confused.
So i have a private npm module at git#github.com:myModule/MySweetModule.git
I have just published the latest tagged version. Unfortunately i cannot figure out how that works, BUT it works off your master. SOOO your master branch can be your integration branch and you have stage branch for building up the next version. Upon version completion, just merge it into master and increment your private repo's version (so your private repo now went from 1.0.0 to 1.0.1). If you call npm install it will update your repo if the master's package.json version is greater than current working repo. It will always take the latest repo.
That seems like it sucks
I agree. So lets do it a better way! If you tags for your private repo releases you can reference them by "custom": "git+ssh://git#github.com:usr/proj.git#TAG_NAME"
So it i have a tag called 0.1.0, then i would have the url in package.json versioned like so. "custom": "git+ssh://git#github.com:usr/proj.git#0.1.0"
I believe that this is the best approach to your answer. But i am not a gitanista
WARNING
If you try to go back a version, it appears it does not work. so from version 0.2.2 to 0.2.1 it will not update your project. Make sure you do npm remove myProj then npm install if you roll back a version.
manually updating that specific package did the trick for me.
and to do that automatically i added this postinstall script to my package.json
"scripts": {
...
"postinstall": "npm update custom"
}
I encountered this question and all the answers had their own set of issues so I had to find a better means.
I have discovered a newer way to prevent this npm issue with package upgrades on install within the docs (this MAY require newer versions of npm):
Ensure you are tagging versions in your repo.
Then you can include your repo using this slightly modified URL:
git+ssh://git#<repo url>.git#semver:<tag/package version>
This behaves MUCH better and has no issues with downgrading or upgrading the version as I have seen thus far.
Manually updating the package, as suggested by #Nestoro also worked for me:
npm update
npm install <your package name>

Categories

Resources