您要请求功能还是报告错误?
一个错误。
目前的行为是什么?
我正在尝试添加etcher-image-write
模块,其中包含 Windows 特定的可选依赖项:
...
"optionalDependencies": {
"diskpart": "^1.0.0"
},
...
diskpart
模块在其package.json
声明只能安装在 Windows 上:
..
"os": [
"win32"
],
..
但是,当我尝试添加etcher-image-write
时得到以下输出:
$ yarn add etcher-image-write
yarn add v0.19.0
info No lockfile found.
warning npm-shrinkwrap.json found. This will not be updated or respected. See https://yarnpkg.com/en/docs/migrating-from-npm for more information.
[1/4] 🔍 Resolving packages...
warning [email protected]: this package is no longer updated or maintained
warning [email protected]: electron-prebuilt has been renamed to electron. For more details, see http://electron.atom.io/blog/2016/08/16/npm-install-electron
warning file-tail > [email protected]: this package is no longer updated or maintained
warning electron-builder > progress-stream > through2 > xtend > [email protected]:
warning electron-packager > asar > mksnapshot > request > [email protected]: use uuid module instead
[2/4] 🚚 Fetching packages...
warning [email protected]: The platform "darwin" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
warning [email protected]: The platform "darwin" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
error [email protected]: The platform "darwin" is incompatible with this module.
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
如果当前行为是错误,请提供重现步骤。
yarn add etcher-image-write
什么是预期行为?
由于diskpart
是etcher-image-write
的可选依赖项,因此如果存在平台不匹配,Yarn 不应抛出错误,而只需将其省略,就像 npm 一样。
请提及您的 node.js、yarn 和操作系统版本。
嗯,等等。 这仅在我从https://github.com/resin-io/etcher运行yarn add etcher-image-write
时发生,否则它安装得很好,这很奇怪。
好的,我会在这里重写问题描述,这样原始消息就不会丢失:
我们期待为https://github.com/resin-io/etcher迁移到 Yarn yarn install
,我会得到以下结果:
$ git clone https://github.com/resin-io/etcher
$ yarn install
yarn install v0.19.0
info No lockfile found.
warning npm-shrinkwrap.json found. This will not be updated or respected. See https://yarnpkg.com/en/docs/migrating-from-npm for more information.
[1/4] 🔍 Resolving packages...
warning [email protected]: this package is no longer updated or maintained
warning [email protected]: electron-prebuilt has been renamed to electron. For more details, see http://electron.atom.io/blog/2016/08/16/npm-install-electron
warning file-tail > [email protected]: this package is no longer updated or maintained
warning etcher-image-write > progress-stream > through2 > xtend > [email protected]:
warning electron-packager > asar > mksnapshot > request > [email protected]: use uuid module instead
[2/4] 🚚 Fetching packages...
warning [email protected]: The platform "darwin" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
warning [email protected]: The platform "darwin" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
error [email protected]: The platform "darwin" is incompatible with this module.
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
我最初虽然这个问题与etcher-image-write
,因为在yarn add etcher-image-write
上执行etcher/
产生相同的结果,但问题似乎来自removedrive
。
此模块是 Etcher 本身的可选依赖项:
...
"optionalDependencies": {
"elevator": "^2.1.0",
"removedrive": "^1.1.1"
},
..
它是一个仅限 Windows 的软件包:
...
"os": [
"win32"
],
...
来自原始问题的相同论点成立:
由于removedrive
是etcher
的可选依赖项,因此如果存在平台不匹配,Yarn 不应抛出错误,而只需将其省略,就像 npm 一样。
我也有这个问题,如下:
https://github.com/alykoshin/winston-winlog3
依赖于一个仅限 Windows 的模块:
https://github.com/alykoshin/node-windows
我们的 package.json 中有以下内容
"optionalDependencies": {
"winston-winlog3": "^1.0.6"
},
错误:
error [email protected]: The platform "darwin" is incompatible with this module.