In bower (a node dependency package manager), on some dependencies the version is preceded by a tilde. What does this mean?
{
"name": "mean",
"version": "1.0.0",
"dependencies": {
"bootstrap": "3.0.0",
"angular": "~1.0.6"
}
{
~1.2.3 := >=1.2.3-0 <1.3.0-0 "Reasonably close to 1.2.3". When using
tilde operators, prerelease versions are supported as well, but a
prerelease of the next significant digit will NOT be satisfactory, so
1.3.0-beta will not satisfy ~1.2.3.
From the documentation of the underlying semver
Related
npm version: 7.24.2
someone know update a child dependency, I have the dependency:
vue-tel-input
and this dependency has the dependency libphonenumber-js with version: ^1.9.6
I want to update this libphonenumber-js to ^1.10.12
I already tried with:
https://docs.npmjs.com/cli/v8/configuring-npm/package-json?fbclid=IwAR2lAcPyu2XTTR5srKIEOpr1v8HM6UZL66WC42IG_8c3UU_u_vXeSPAL8J8#overrides
https://stackoverflow.com/a/48524488
any idea?
I don't think you can do that easily with your current setup.
you can either update to npm v8.3+, which supports overrides or use yarn with resolutions
more info:
overrides(npm):
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
package.json
"overrides": {
"vue-tel-input": {
"libphonenumber-js": "^1.10.12"
}
}
resolutions(yarn):
https://classic.yarnpkg.com/en/docs/selective-version-resolutions/
package.json
"resolutions": {
"libphonenumber-js": "^1.10.12"
}
alternatively, you can manage the package-lock.json file manually to define the version
"vue-tel-input": {
"version": "5.11.0",
"resolved": "https://registry.npmjs.org/vue-tel-input/-/vue-tel-input-5.11.0.tgz",
"integrity": "sha512-kw13LdbnSH+Zk5Qb06vflG7Abu6QsM1cQyKvTA9T4kaZeARvyvKo9YZmziy7WiSuar932DWRjGI0SJnban4a2A==",
"requires": {
"core-js": "^3.14.0",
"libphonenumber-js": "^1.9.6",
"vue": "^2.6.14"
}
},
you might be able to change "libphonenumber-js": "^1.9.6" to use ^1.10.12
but wanted to point out that when I did a fresh install, it did install 1.10.12
"node_modules/libphonenumber-js": {
"version": "1.10.12",
"resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.12.tgz",
"integrity": "sha512-xTFBs3ipFQNmjCUkDj6ZzRJvs97IyazFHBKWtrQrLiYs0Zk0GANob1hkMRlQUQXbJrpQGwnI+/yU4oyD4ohvpw=="
},
Because ^ will update to the latest minor version (2nd number), it should use a specific version, so in this case, because you're going from 1.9.* to 1.10.* and using ^1.9.6 you may be able to just remove your lock file and re-install to get 1.10.12
For example, given two node modules, a and b.
a/package.json
{
"name": "a",
"version": "1.0.0",
"dependencies": {
"fastify": "3.24.0"
}
}
b/package.json
{
"name": "b",
"version": "1.0.0",
"dependencies": {
"a": "*",
"fastify": "^3.24.0"
}
}
After running npm install in b, there are two versions of fastify in b's node_modules. One is node_modules/fastify (3.25.0), the other is node_modules/a/node_modules/fastify (3.24.0), which makes the instances created by fastify in the two modules (a and b) respectively belong to different classes and causes problems.
It's weird that npm doesn't just choose to use one version (such as 3.24.0) of the same package that fits all semver conditions.
If a package.json file has an engines field like this:
"engines" : {
"node" : "~>12"
},
What does the ~> mean?
engines Sets which versions of Node.js and other commands this package/app work on
example:
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0",
"yarn": "^0.13.0"
}
So if you see ~>12.0.1 it means to install version 12.0.1 or the latest patch version such as 12.0.4
I tried to specify the node engine in a package.json to accept both 8 and 10 version.
I tried to type this:
"engines": {
"node": "8.x|10.x"
},
But running yarn results in:
The engine "node" is incompatible with this module. Expected version "8.x|10.x"
If I replace with:
"engines": {
"node": "10.x"
},
... it works (i.e no error).
Is there a way to accept two versions of node engine in a package.json?
You just need the double pipe || instead of a single.
"engines": {
"node": "^8 || ^10"
}
Would match either v8.x.x or v10.x.x but not v9.
You can read more about it here, or https://github.com/npm/node-semver#versions
See the documentation which includes examples.
Provide a space separated list of engines with greater/less than symbols.
{
"engines" : {
"node" : ">=8.0.0 <11.0.0"
}
}
My bower.json:
{
"...." : "...."
"name": "myproject",
"dependencies": {
"angular": "1.2.20",
"bootstrap": "latest"
}
}
I'd like to replace "latest" in bootstrap dependency by its actual version number. Is there any way to do that via bower command ? (not via a custom script)
No, bower doesn't have shrinkwrap feature.
It is a long-standing issue: https://github.com/bower/bower/issues/505