package.json specifying a version for a library - npm

We have following requirements in our package.json,
"three-orbitcontrols": "^2.102.2"
in one computer, node_modules/three-orbigcontrols/package.json has
"_from": "three-orbitcontrols#2.102.2",
"_id": "three-orbitcontrols#2.102.2",
in another computer,
"_from": "three-orbitcontrols#2.102.2",
"_id": "three-orbitcontrols#2.110.1",
So specifying ^2.102.2 doesn't force the version (2.110.1 is installed`
What's the correct way of specifying specific 2.102.2 ?

Related

Lauching dotnet fails ("dotnet" is not a file of a symlink)

The default vscode configuration for debugging ASP.NET core contains the following:
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
...
The preLaunchTask fails for me with the following error:
The terminal process failed to launch: Path to shell executable "dotnet" is not a file of a symlink.
I have had this problem before, not on the preLaunchTask but on the main program execution. That I could work around by doing a replace all "dotnet" -> "/usr/bin/dotnet" in ~/.vscode/extensions/ms-dotnettools.csharp-1.**.*/dist/extensions.js + a vscode restart. However, this workaround doesn't work for the preLaunchTask. (And having to do this for every update of that extension in annoying).
Given that I'm a linux noob, it's probably not omnisharp/vscode related but could be something I did wrong in Ubuntu 18.04.
Does anybody know what the error means, and how to fix it? Or even how to debug this problem?
I've already reinstalled vscode, .net5, and my global $PATH env does contain /home/<username>/.dotnet/tools:/usr/bin/dotnet. Other than that I don't know what to do.
in tasks.json file change from
"type": "process" to "type": "shell"

error: no browser selected to run against, but i mentioned it in .testcafe.json

I have created .testcaferc.json, I mentioned the browser and src in it. so I should be able to run tests without putting this in the command line.
But it does not seem to be reading my config file from the project folder.
{
"src": "c:/Testcafe/Login.js",
"browsers": "firefox",
"reporter": {
"name": "html",
"output": "reports/report.html"
},
"takeScreenshotsOnFails": true,
"screenshotPath": "/screenshots/"
}
Actual:
Using locally installed version of TestCafe.
ERROR No browser selected to test against.
Type "testcafe -h" for help.
Expected:
I should not ask for browser and test file parameter as both are provided in config file.
The configuration file is a feature added in v1.0.0. If you upgrade from 0.20.5 to 1.0.0 or later, you will be able to use the configuration file for your tests.
Release Notes:
https://github.com/DevExpress/testcafe/releases/tag/v1.0.0

Why does “npm install” changes package-lock.json and adds tild or cap?

I have npm version 6 installed on my machine. I have the following content in package-lock.json:
{
"name": "Project",
"version": "0.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"package1": {
"version": "0.1.2"
},
"package2": {
"version": "0.2.2"
}
}
}
Whenever I am running npm install it's updating my package-lock.json and new contact is like:
{
"name": "Project",
"version": "0.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"package1": {
"version": "^0.1.2"
},
"package2": {
"version": "~0.2.2"
}
}
}
I am expecting to not add ~ tild or cap ^ into the version of package-lock. I am not even adding or removing any package before npm install. Lock file is very big so it's hard to maintain changes manually.
What is the problem? How should I install new packages without affecting old versions?
As per my understanding and whatever I searched on this,I can able to say that,this(package-lock.json) behavior is refactor to make traceability of dependencies easier, even if getting some large lock file diffs in the meantime is not ideal.
package-lock.json should be the tool and mechanism what is responsible to keep everything consistent, so the trust in it is unavoidable and necessary.
Documentation
package-lock.json describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.
For example, package.json is:
...
"glamor": "^2.10.00"
...
In package-lock, there are links to specific versions, for example, https://registry.npmjs.org/glamor /-/glamor-2.20.40.tgz
The change only touched the format of the require description.
It was:
"requires": {
"glamor": "2.20.40"
}
Became:
"requires": {
"glamor": "^2.0.0"
}
Semver was not broken (2.20.40 is still matching to ^2.0.0), and the links remained in place
When the package version is updated, the package will still be taken from the link file (there is an old version of the package)
To update the link in the lock file, you must either change package.json or make npm update. For more reference npm issues
More explanation on this:
Let's say that you use pinned versions of dependencies 'aaa', 'bbb' and 'ccc'. Let's say they each depend on 'zzz' like so:
aaa depends on zzz#^1.0.0
bbb depends on zzz#^1.1.0
ccc depends on zzz#^1.0.1
i.e. all three of them depend on a range of zzz, and not an exact version.
And let's say that the latest version of zzz is 1.5.0.
Both before and after this change, it's pretty obvious that the resolved version of zzz should be 1.5.0, so the only difference is how the package-lock.json is structured and documents this sub-dependency.
Before, the lock file would show that all three of them depend on zzz#1.5.0, and the resolved version of z is 1.5.0.
Now, it documents the actual "original" dependency versions (e.g. ^1.0.0, ^1.1.0, etc) for each dependency, but still shows the resolved version of z as 1.5.0.
Then consider what happens when zzz#1.5.1 is released:
Before, the lock file would need to update from z#1.5.0 to z#1.5.1 in all four places.
Now, the lock file only needs to update the resolved version of z to 1.5.1 while the dependencies can keep the ^1.0.0, ^1.1.0, and ^1.0.1 because they haven't changed.
As I mentioned previously in the thread, you still get the exact same node_modules in both cases. The advantages of the new approach are:
You get to see what the dependencies actually require (e.g. a range, and not an exact version). before, you could not tell if aaa actually required exactly zzz#1.5.0 or that it was instead zzz#^1.0.0.
Instead of four lines changing in the lock file, you get only one. It's less churn, and it's more clear what's happened.
As an aside, yarn uses a similar concept with yarn.lock. e.g. here's an example where #sindresorhus/is is pinned, but it's sub-dependency symbol-observable is not:
"#sindresorhus/is#0.10.0":
version "0.10.0"
resolved "https://registry.yarnpkg.com/#sindresorhus/is/-/is-0.10.0.tgz#f42dd6a9d12cd79fa6f53b27cf5bea3a30d2cafa"
dependencies:
symbol-observable "^1.2.0"

Get OpenJDK to work with Packr

Using the JSON config, I specify an opendjk prebuild, containing a JRE. (The exact one specified in packr's example in the readme, actually)
It packs my JAR into a mac executable successfully.
I run the executable, and it works as expected on my Yosemite (where I also have Oracle JDK installed)
When I run the executable on another mac with Yosemite (which does not have any JDK installed), it throws java/lang/NoClassDefFoundError: java/lang/Object
But it should use the JRE specified and packed with the executable by packr. It Should not depend on the system to have a JDK installed.
EDIT: Added config.json code -
{
"platform": "mac",
"jdk": "/Users/absolute/path/to/jdk/openjdk-1.7.0-u45-unofficial-icedtea-2.4.3-macosx-x86_64-image.zip",
"executable": "myApp",
"appjar": "/Users/absolute/path/to/jar/MyJar.jar",
"mainclass": "self/edu/Main",
"vmargs": [
"-Xmx256M"
],
"resources": [
],
"minimizejre": "soft",
"outdir": "out-mac"
}

How can I check latest available version of Symfony with any API?

I want to get latest available version of Symfony Framework. Can I get it with any available API (maybe with Composer or any web services)?
The official Symfony roadmap API can give you the most recent LTS, Stable, and Beta versions available.
Making a call to
https://symfony.com/roadmap.json?version=all
Will return something similar to
{
"symfony_versions": {
"lts": "2.8.5",
"stable": "3.0.5",
"beta": "3.1.0-DEV"
},
"latest_stable_version": "3.0",
"version": "all",
"error_message": "Wrong version format (should be X.Y or X.Y.Z where X, Y, and Z are integers)."
}
Note that this is an undocumented use of the API, as you trick it by not supplying a valid version number. This prompts the API to return a JSON object listing the current versions. Although undocumented, I think you can safely use this because the Symfony project has a strong history of maintaining backwards compatibility.
packagist.org actually has an undocumented API. All you have to do is go to any package page and add .json to the URL.
For example, this is the page for symfony/symfony and its respective JSON formatted version.
The path "package"->"versions" is an object whose keys are version numbers and whose values are package description objects. These have a version_normalized key that you could use to sort the packages to find the latest version.
"package": {
"name": "symfony/symfony",
"description": "The Symfony PHP framework",
"time": "2011-09-29T17:29:54+00:00",
"maintainers": [
{
"name": "fabpot"
}
],
"versions": {
...
"v2.5.8": {
"name": "symfony/symfony",
"description": "The Symfony PHP framework",
"keywords": [
"framework"
],
"homepage": "http://symfony.com",
"version": "v2.5.8",
"version_normalized": "2.5.8.0",
...
Packagist is your friend (that's where the composer stuff comes from)
https://packagist.org
https://packagist.org/feeds/package.symfony/symfony.rss
https://packagist.org/feeds/package.symfony/symfony.atom
EDIT
2nd solution is via github API
https://github.com/symfony/symfony/releases
more infos at https://developer.github.com/v3/repos/#list-tags