看起来yarn不像npm那样将node-gyp标志传递给本机包。
例如,当尝试使用以下命令安装sqlite3@3.1.6时:
npm install sqlite3@3.1.6 \
--build-from-source \
--sqlite_libname=sqlcipher \
--sqlite=`brew --prefix` \
--verbose我们成功安装了带有sqlcipher扩展的sqlite3,这要归功于传递了--sqlite_libname和--sqlite,它们是sqlite3的binding.gyp中的specified。
但是,当尝试使用yarn,并运行我认为是等效命令的时候,看起来这些标志没有被遵守:
yarn add sqlite3@3.1.6 \
--force \
--build-from-source \
--sqlite_libname=sqlcipher \
--sqlite=`brew --prefix` \
--verbose使用npm时,无法识别的命令行参数将转换为gyp标志。
对于yarn,这似乎不起作用。
有没有办法通过yarn实现这一功能?
发布于 2019-03-27 09:06:38
目前,这可以通过使用npm_config_{snake_case_param}=true/false格式的环境变量来实现
例如,npm install --build-from-source=true变为:
npm_config_build_from_source=true yarn install文档记录在这里,https://yarnpkg.com/lang/en/docs/envvars/#toc-npm-config
发布于 2017-08-20 13:49:49
Yarn不会自动将install命令的--参数暴露给生命周期脚本(依赖项的package.json中的预/后/安装脚本)。下面是Yarn为脚本执行https://github.com/yarnpkg/yarn/blob/master/src/util/execute-lifecycle-script.js#L39构建环境的代码。
您可以通过.yarnrc中的env设置传递特定值,它还会基于.ya You /.npmrc配置构建npm_config_*设置。
https://stackoverflow.com/questions/45758461
复制相似问题