It looks like yarn
does not pass node-gyp flags to native packages the way npm
does.
For example when attempting to install [email protected] with:
npm install [email protected] \
--build-from-source \
--sqlite_libname=sqlcipher \
--sqlite=`brew --prefix` \
--verbose
we get a successful installation of sqlite3 with sqlcipher extensions, due to passing --sqlite_libname
and --sqlite
, which are specified in sqlite3's binding.gyp
.
But, when attempting to use yarn
, and running what I would think to be the equivalent command, it looks like the flags aren't honored:
yarn add [email protected] \
--force \
--build-from-source \
--sqlite_libname=sqlcipher \
--sqlite=`brew --prefix` \
--verbose
With npm
unrecognized command line arguments are converted to gyp flags.
With yarn
that doesn't seem to work.
Is there a way to get this functionality with yarn
?
This is currently possible by using environment variables on the format npm_config_{snake_case_param}=true/false
For example, npm install --build-from-source=true
becomes:
npm_config_build_from_source=true yarn install
It's documented here https://yarnpkg.com/lang/en/docs/envvars/#toc-npm-config
Yarn does not automatically expose --
arguments of install command to lifecycle scripts (pre/post/install scripts in package.json of dependencies).
Here is the code where Yarn builds Env for the script execution https://github.com/yarnpkg/yarn/blob/master/src/util/execute-lifecycle-script.js#L39.
You can pass specific values via env
setting in .yarnrc and also it builds npm_config_*
settings based on .yarnrc/.npmrc configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With