yarn icon indicating copy to clipboard operation
yarn copied to clipboard

Pass arguments to install scripts like npm

Open danbopes opened this issue 7 years ago • 3 comments

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.

danbopes avatar Jan 18 '18 13:01 danbopes

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

JCMais avatar Mar 27 '19 00:03 JCMais

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

👎🏻

As written, this is not cross-platform, only working on POSIXy shells/systems.

rivy avatar Jul 15 '22 17:07 rivy

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

👎🏻

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

JCMais avatar Jul 16 '22 21:07 JCMais