我如何配置我的 package.json 以便某些软件包只安装在 Windows 上?
How can I configure my package.json so that certain packages will only install on Windows?
我正在为我的应用程序使用 "msnodesqlv8": "0.2.3" npm 包 运行 Windows 上的一些 MSSQL 脚本,但在 Mac 上我可以由于此错误,'安装所有其他软件包:
Macbook-Pro jeremy$ npm install
npm ERR! Darwin 15.5.0
npm ERR! argv "/Users/jeremy/.nvm/versions/node/v6.1.0/bin/node" "/Users/jeremy/.nvm/versions/node/v6.1.0/bin/npm" "i"
npm ERR! node v6.1.0
npm ERR! npm v3.8.6
npm ERR! code EBADPLATFORM
npm ERR! notsup Not compatible with your operating system or architecture: msnodesqlv8@0.2.3
npm ERR! notsup Valid OS: win32
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: darwin
npm ERR! notsup Actual Arch: x64
npm ERR! Please include the following file with any support request:
npm ERR! /Users/jeremy/code/lyfeboat/mitchell-sql-feathers/npm-debug.log
有没有办法配置我的 package.json 以便在所有非 windows 系统上忽略此软件包?
我不确定是否有更好的方法,但我能够使用 package.json 中的 optionalDependencies 属性 获得所需的行为。
https://docs.npmjs.com/files/package.json#optionaldependencies
这是我使用的格式:
...
"optionalDependencies": {
"msnodesqlv8": "0.2.3"
},
...
预期输出:
Macbook-Pro jeremy$ npm install
...
*installed other packages normally*
...
npm WARN optional Skipping failed optional dependency //msnodesqlv8:
npm WARN notsup Not compatible with your operating system or architecture: msnodesqlv8@0.2.3
我正在为我的应用程序使用 "msnodesqlv8": "0.2.3" npm 包 运行 Windows 上的一些 MSSQL 脚本,但在 Mac 上我可以由于此错误,'安装所有其他软件包:
Macbook-Pro jeremy$ npm install
npm ERR! Darwin 15.5.0
npm ERR! argv "/Users/jeremy/.nvm/versions/node/v6.1.0/bin/node" "/Users/jeremy/.nvm/versions/node/v6.1.0/bin/npm" "i"
npm ERR! node v6.1.0
npm ERR! npm v3.8.6
npm ERR! code EBADPLATFORM
npm ERR! notsup Not compatible with your operating system or architecture: msnodesqlv8@0.2.3
npm ERR! notsup Valid OS: win32
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: darwin
npm ERR! notsup Actual Arch: x64
npm ERR! Please include the following file with any support request:
npm ERR! /Users/jeremy/code/lyfeboat/mitchell-sql-feathers/npm-debug.log
有没有办法配置我的 package.json 以便在所有非 windows 系统上忽略此软件包?
我不确定是否有更好的方法,但我能够使用 package.json 中的 optionalDependencies 属性 获得所需的行为。
https://docs.npmjs.com/files/package.json#optionaldependencies
这是我使用的格式:
...
"optionalDependencies": {
"msnodesqlv8": "0.2.3"
},
...
预期输出:
Macbook-Pro jeremy$ npm install
...
*installed other packages normally*
...
npm WARN optional Skipping failed optional dependency //msnodesqlv8:
npm WARN notsup Not compatible with your operating system or architecture: msnodesqlv8@0.2.3