I know what peer dependencies are in package.json and the reason why the warning
....has unmet peer dependency ....
will appear, also I know that npm v7 will install them but currently I am using yarn and I don't want the peer dependencies to be installed (there are many of them and probably there will be a chance for conflicts).
Is there any way to silence these warnings? I know there is an option for yarn install -silent but it didn't work and I still have these warnings... in my case there are a lot of them.
Related
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.
I got a lot of unmet peer dependency errors during a project installation using yarn. And I didn't take a screenshot of those or anything. How do I see all those warning again? Is there a command for that?
The following command works while using yarn as the package manager:
yarn install --check-files
This sort of worked for me: yarn --ignore-scripts --audit.
I think it showed a few less warnings than when I ran a fresh install, but it is at least showing some of the previous warnings for me. I threw --ignore-scripts in there because in Nx/Angular repos, you might have a lengthy ngcc command set up in your package.json. --audit's main purpose is to actually show you how many vulnerabilities you have in your dependencies, but as a side-effect, it appears to be running whatever code shows the warnings. If there is a better solution, I'd also like to know.
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.
I am learning about angular universal. At this step :
ng add #nguniversal/express-engine --clientProject angular.io-example
It is supposed to add some files namely : main.server.ts, but it is not doing anything. I tried the same command with sudo too. What is the problem?
FYI, I started off with a clean project so there indeed were dependencies missing, your case might be a bit different, depending on whether you already have some of the dependencies already installed.
Since it was doing the same for me too as mentioned, I went ahead and used
npm i #nguniversal/express-engine
which showed me some warnings about some dependencies which were missing.
In my case they were,
npm install ajv-keywords
and
npm install #angular/platform-server
then I ran
npm install #nguniversal/express-engine
to install the package, then
ng add #nguniversal/express-engine
which added the necessary dependencies you were asking for. Hope this is easy to follow
When running yarn check, I see:
info fsevents#1.2.4: The platform "linux" is incompatible with this module.
info "fsevents#1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
This GitHub comment says that the message can be safely ignored.
Is there a way to prevent it from occurring in the first place?
Not sure about yarn check but for installing/updating: yarn --silent or even better yarn --silent --ignore-optional
yarn --silent installs optional deps, but without the output.
Note: If running with --ignore-optional flag you may be dependent on some of the optional dependencies without realising it. So I recommend deleting your node_modules folder and yarn.lock file and then running yarn --ignore-optional before testing your project. If it turns out there were optional deps you required, then add them as [dev] deps [accordingly].
Although if it was just fsevents and that was never being installed, no worries.
Currently it does not seem possible to prevent messages about optional dependencies which are not explicitly required.
See the following yarn GitHub issues:
[FR] a way to ignore packages #4611
Add flag to ignore individual optional packages #5251