yarn
yarn copied to clipboard
Pass arguments to install scripts like npm
Do you want to request a feature or report a bug? Feature Request
What is the current behavior? Trying to install node-serialport, and it recommends to install via: "npm install serialport --build-from-source". It doesn't appear possible that I can emulate this command via yarn. See also this stackoverflow question.
What is the expected behavior? Running a command through yarn, it should install and build-from-source. Running subsuqent "yarn install"s it should continue to build from source, or not attempt to build with the default parameters to node-gyp.
For anyone looking into this issue, this is currently possible, idk when it was implemeted.
You can pass npm flags via env vars, by using npm_config_{snake_case_param}=true
, so npm install --build-from-source
becomes npm_config_build_from_source=true yarn install
It's documented here https://yarnpkg.com/lang/en/docs/envvars/#toc-npm-config
You can pass npm flags via env vars, by using
npm_config_{snake_case_param}=true
, sonpm install --build-from-source
becomesnpm_config_build_from_source=true yarn install
👎🏻
As written, this is not cross-platform, only working on POSIXy shells/systems.
You can pass npm flags via env vars, by using
npm_config_{snake_case_param}=true
, sonpm install --build-from-source
becomesnpm_config_build_from_source=true yarn install
👎🏻
As written, this is not cross-platform, only working on POSIXy shells/systems.
I have not tested it, but I suppose npx cross-env npm_config_build_from_source=true yarn install
should work in a cross platform way