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

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.

Related

Is there an equivalent of 'yarn why' for 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

Is it possible to disable ESLint when running npm run build for a React app?

I have an app initiated using Create React App, so npm run build runs react-scripts build. I recently installed prettier and so added a .eslintrc.json file to the project root to load the prettier plugin. npm run build works as expected locally, but, when deploying the app to Heroku, npm run build tries to run ESLint and fails because the plugins are devDependencies rather than dependencies.
Failed to load plugin 'prettier' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-prettier'
From prior wrangling with a similar issue, I know that I can set NPM_CONFIG_PRODUCTION=false in Heroku so that it will install devDependencies, which actually does resolve the deployment issue. Nevertheless, I'm curious to learn if there's another solution that doesn't require setting NPM_CONFIG_PRODUCTION=false.
Is it possible to prevent npm run build in this scenario from running ESLint altogether or to prevent it from trying to access the plugins specified in .eslintrc.json? I acknowledge that adding .eslintrc.json to .gitignore is one solution, but I want the ESLint configuration in my repo.
you can run "npm run eject" to generate webpack configuration files, and then modify "webpack.config.js",delete the eslint configuration

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.

'ng add #nguniversal/express-engine' not working

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

Silence 'info fsevents#1.2.4: The platform "linux" is incompatible with this module.'

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

Resources