Is there an equivalent of 'yarn why' for pnpm? - pnpm

There is a particular sub-dependency of my project that is failing to install properly in pnpm. I'm not sure why the dependency (es5-ext) is required.
When using yarn, I can ask "yarn why [package-name]" to find out why a package is needed.
Is there an equivalent in pnpm?

pnpm why es5-ext will work with pnpm. See the docs: https://pnpm.io/cli/why

Related

Can I propagate "yarn install" options through the bb (bobril build)

I'm using Bobril and Bobril build and also use third party packages which have optional dependencies. In "yarn install" I would like to avoid to this kind of issues, through "yarn install --ignore-optional":
info This module is OPTIONAL, you can safely ignore this error
warning Error running install script for optional dependency: "node_modules\\cpu-features: Command failed.
Currently there is no such way.
I am thinking to make this new default.
BTW: Feel free to use Project Github issues to request features: https://github.com/bobril/bbcore/issues
Edit: It is now new default in 1.57+ version.

Yarn 2 and dart sass with create react app

I've been trying to update a Create React App to use yarn 2 and plug and play (PNP). When I do use nodeLinker: node-modules in the .yarnrc.yml, I can successfully start the dev-server. Without it, I end up with
./src/App.scss (./.yarn/$$virtual/css-loader-virtual-fe3fa7be11/0/cache/css-loader-npm-3.4.2-300ee159b3-2.zip/node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./.yarn/cache/postcss-loader-npm-3.0.0-f4ab99b685-2.zip/node_modules/postcss-loader/src??postcss!./.yarn/cache/resolve-url-loader-npm-3.1.1-cf1a268137-2.zip/node_modules/resolve-url-loader??ref--6-oneOf-5-3!./.yarn/unplugged/sass-loader-virtual-14ae4e1150/node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-5-4!./src/App.scss)
Error: A package is trying to access a peer dependency that should be provided by its direct ancestor but isn't
Required package: node-sass (via "node-sass")
Required by: sass-loader#virtual:74ba539c0b6c6c8346ea151c91664bff0bef13782983a6f90ddf1a26160140360771dcf40d0863b46ff7add674bc2c42a37daea25f24f4ea96f7843786460ecd#npm:8.0.2 (via /Users/me/color-contrast-matrix/.yarn/unplugged/sass-loader-virtual-14ae4e1150/node_modules/sass-loader/dist/)
It looks like yarn 2 provides a way of overriding a packages dependencies. You have to provide the missing dependency, at least in this case.
From the docs current link:
Some packages may have been specified incorrectly with regard to their
dependencies - for example with one dependency being missing, causing
Yarn to refuse it the access. The packageExtensions fields offer a way
to extend the existing package definitions with additional
information. If you use it, consider sending a PR upstream and
contributing your extension to the plugin-compat database.
After installing node-sass and adding this config, compilation succeeded.
# .yarnrc.yml
packageExtensions:
'sass-loader#*':
optionalDependencies:
node-sass: '*'
Building on wegry's answer, a better way would be to fix up react-scripts, since that's where the missing peer dependency is.
#.yarnrc.yml
packageExtensions:
'react-scripts#*':
peerDependencies:
node-sass: ^4.0.0 || ^5.0.0' # Or sass: ^1.3.0'
I'm using versions that match the peerDependency of the version of sass-loader that is currently depended on by react-scripts. (I hope by the time the next version of react-scripts comes out, they'll have fixed this bug.)
What this is doing, is telling Yarn that react-scripts really should have peer-depended on sass (and also node-sass for that matter), so that sass-loader can use them.
sass-loader itself has defined its dependencies correctly.

Why can't I run yarn start?

For a few days I have been getting these messages:
*> yarn run v1.21.1 $ react-scripts start
There might be a problem with the project dependency tree. It is
likely not a bug in Create React App, but something you need to fix
locally.
The react-scripts package provided by Create React App requires a
dependency:
"eslint": "^6.6.0"
Don't try to install it manually: your package manager does it
automatically. However, a different version of eslint was detected
higher up in the tree:
/home/sol/Repository/node_modules/eslint (version: 6.3.0)
Manually installing incompatible versions is known to cause
hard-to-debug issues.
If you would prefer to ignore this check, add
SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That will
permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact
order:
Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
Delete node_modules in your project folder.
Remove "eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem. If this has
not helped, there are a few other things you can try:
If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
Check if /home/sol/Repository/node_modules/eslint is outside your project directory.
For example, you might have accidentally installed something in your home folder.
Try running npm ls eslint in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed eslint.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file
in your project. That would permanently disable this preflight check
in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-)
We hope you find them helpful!
error Command failed with exit code 1. info Visit
https://yarnpkg.com/en/docs/cli/run for documentation about this
command.*
I tried everything above, but nothing helps and I'm really upset about this situation because I can't get my code to work.
Can someone help me with easy instructions because I don't have time anymore to try and find a solution to the problem.
I could not solve the problem:
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"eslint": "^6.6.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of eslint was detected higher up in the tree:
/Users/elvestrindade/node_modules/eslint (version: 6.2.2)

Yarn can't add dependency via git+ssh because package doesn't have a "_uid"

We have a dependency that lives on private GitLab instance, but we can't get yarn to add it.
Installing the package like this:
yarn add git+ssh://git#privateserver.org:team/package-name.git
results in this error:
error Package "package-name#0.9.2" doesn't have a "_uid".
I'm thinking this is yarn-specific because using npm does work ... e.g. this command successfully installs the package:
npm install --save git+ssh://git#privateserver.org:team/package-name.git
I've looked through yarn's documentation and gone through pages of google results, but can't really find any information the _uid. Anyone have any ideas what's going on here?
Think we have it figured out. It appears that in our case, we have to supply a hash ... either a partial SHA or tag.
So this works:
yarn add git+ssh://git#privateserver.org:team/package-name.git#8050948
and so does this:
yarn add git+ssh://git#privateserver.org:team/package-name.git#master

Adding git repository with yarn results in error

I am just learning about yarn and npm.
I want to use a particular package that crashes my app. I found a project issue which looks like fix has been implemented and merged with master. A comment says npm package has not been updated yet.
I have added the package to my project:
yarn add react-widgets
I thought I could use yarn to add the package via git repository to get fixed version.
The package I want is
https://github.com/jquense/react-widgets
So I tried
yarn add https://github.com/jquense/react-widgets.git
I get error:
error Package "undefined#undefined" doesn't have a "name".
Firstly, is this error a problem with my use of yarn or a problem with react-widgets repository? I am assuming it should work to add it like this so please correct me if I am wrong.
Also, can I assume that if there is an updated npm package, that I will be able to update with yarn at that time?
I'm afraid it is impossible to do now. This git repo is actually several packages inside(main package is here) one repo and root package.json is not valid one - it doesn't have name description and this is fail reason. There is discussion about supporting this in yarn, but it hasn't been implemented yet(in npm too).

Resources