How to pump semantic version of git dependency in yarn2? - yarnpkg

"dependencies": {
"mylib": "git+https://github.com/user/mylib#semver:^0.1.0"
}
How can I update a git dependency to the latest matched semantic version using yarn v2?
With npm or yarn v1 I could do it via yarn upgrade [package-name].
But seems no luck for yarn2 yarn up [package-name].
It always throws me:
mylib#git+https://github.com/user/mylib#semver:^0.1.0 can't be resolved to a satisfying range

Related

How to composer install using a package's composer.lock file?

If I have:
a fresh project
no composer.lock
composer.json like the following
{
"name": "fresh",
"type": "library",
"require": {
"consolidation/robo": "3.0.3"
}
}
Then run composer install
It will install consolidation/robo and update the consolidation/robo internal dependencies instead of using the consolidation/robo internal composer.lock to get a known working version of the library.
How do to get composer install to use https://github.com/consolidation/robo/blob/3.0.3/composer.lock when installing consolidation/robo dependencies instead of running the equivalent of composer update on consolidation/robo?
Currently, it's retrieving a broken internal dependency and I have to outline it in my root composer.json which internal dependency should be retrieved. Where as the https://github.com/consolidation/robo/blob/3.0.3/composer.lock has the working version of the library.
That's the way composer is supposed to work.
Lockfiles for dependencies are ignored, that's by design. If the package you are using has broken version constraints (e.g. it says its compatible with ^2.1 of foo/bar, but in reality was only tested with versions >= 2.1.0 && <= 2.2.2, and installing version 2.3 of foo/bar breaks), it's either becuse foo/bar broke the semver promise, or because the package you depend on was not adequately tested.
What you can do is simply add in your root composer.json:
{
"conflict":
"foo/bar": ">=2.3"
}

How to force yarn to override yarn.lock version and install latest?

I would like to keep all other package versions in tact, but upgrade one single package to the most recent version. How can I do that using yarn?
I know I can delete yarn.lock, and then run yarn install, but I think that will upgrade every package, which I don't want. I just want the most recent version of node-sass, and for that to override the version I have in yarn.lock.
How can this be done?
According to Yarn documentation:
yarn up [package]
yarn up [package]#[version]
yarn up [package]#[tag]
So, to upgrade node-sass, you should run:
yarn up node-sass
The answer by Rodrigo Merlone does not work with yarn-classic. For yarn-classic, a resolution is required.
{
"dependencies": {
"left-pad": "1.0.0",
"c": "file:../c-1",
"d2": "file:../d2-1"
},
"resolutions": {
"d2/left-pad": "1.1.1",
"c/**/left-pad": "^1.1.2"
}
}
More info:
https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/

yarn add not working

I can't install a forked git repository. I want to install version #0.31.0.
yarn add https://github.com/Goldjan/material-components-web.git#v0.31.0
I get the following error:
C:\Users\qjan8\Websites\XXXXXX>yarn add https://github.com/Goldjan/material-components-web.git#v0.31.0
yarn add v1.7.0
[1/4] Resolving packages...
error Can't add undefined: invalid package version undefined.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Does this have to be a name for the package.json?
I had a similar issue, the repo I was trying to add as a dependency didn't have a version field in the package.json. Adding that fixed the issue.

Lerna fails with 404 when trying to link dependency

My structure is as follows:
package.json
lerna.json
packages
myproj-util
package.json
myproj-schema
package.json -- has dev-depenency on myproj-util
Neither project is published to npm yet.
When I run lerna boostrap I get:
❯ lerna bootstrap
lerna info version 2.4.0
lerna info versioning independent
lerna info Bootstrapping 2 packages
lerna info lifecycle preinstall
lerna info Installing external dependencies
lerna ERR! execute callback with error
lerna ERR! Error: Command failed: npm install
lerna ERR! npm ERR! code E404
lerna ERR! npm ERR! 404 Not Found: myproj-util#*
My understanding from the docs is that when running lerna bootstrap it should "check if each dependency is part of the Lerna repo" so it should just be symlinked.
So... why is it not just symlinking my internal dependency? The dependency is under packages/ and the folder name and package name match exactly.
This line from the docs provides a hint:
The version of babel-generator in the package.json of babel-core is satisfied by packages/babel-generator, passing for an internal dependency.
i.e., your internal packages have to match any version constraints otherwise they will be treated as external packages.
Even though my dependency was on "myproj-util": "*", I had forgotten to add a version (any version) to the package.json of myproj-util. Simply adding the version fixed the problem. i.e., the myproj-util package.json looks like:
{
"name": "myproj-util",
"version": "0.1.0"
}

Angular CLI | Mac OS | Dependency Issue during installation

Installing Angluar CLI on MacOS (Sierra, 10.12.4), during which having the following dependency issue.
└─┬ angular-cli#1.0.0-beta.28.3
└── UNMET PEER DEPENDENCY rxjs#^5.0.1
node -v : v7.10.0
npm -v : 4.2.0
Tried removing rxjs completely and let it installed as a part of the dependency tree of the CLI, still gives the same error. Any ideas folks?
Cheer,
D
There is an issue with npm, you can check it out here:
https://github.com/npm/npm/issues/1341#issuecomment-20634338
You can fix your issue by manually installing rxjs#^5.0.1 globally with
npm install -g rxjs#^5.0.1
Hope this resolves your issue.

Resources