7

I'm building a build task for Visual Studio Team Services. In this task I'm using 7zip-bin to package the binary for 7zip for linux, mac and windows.

This is all nice and it would work if I had the ability to deploy just the package.json to the build server, but no... A build task contains all its dependencies at build time.

Is there a way I can force npm to download all OS optional packages somehow? Or will I have to download the file myself during build and extract it?

Right now I'm using

npm install 7zip-bin --save

Which results in:

C:\temp>npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-linux@^1.0.3 (node_modules\7zip-bin\node_modules\7zip-bin-linux):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 7zip-bin-linux@1.0.3: wanted {"os":"linux","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 7zip-bin-mac@^1.0.1 (node_modules\7zip-bin\node_modules\7zip-bin-mac):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 7zip-bin-mac@1.0.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

installing each optional package directly isn't possible, when I run

npm install 7zip-bin-linux --save

on a windows machine, the install is skipped and I get a EBADPLATFORM error.

I understand I can't run these on my machine, but I need to package them in a vsix file (a glorified zip) so I can use them when my build task is running on these other platforms.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341

1 Answers1

3

You should depend on these 3 optional packages, because you never know if 7zip-bin will change it's optional dependencies, which you are using directly.

For example:

dependencies: {
  "7zip-bin-mac": "^1.0.1",
  "7zip-bin-win": "^2.0.2",
  "7zip-bin-linux": "^1.0.3"
}

Using either way, you need to run npm install -f to force the installation.

Frank van Wijk
  • 3,234
  • 20
  • 41
  • When I do that, only one of these 3 is actually downloaded and installed (or I get an error upon install). As a result, the `vsix` is only compatible with the platform that the extension was built on. – jessehouwing Feb 22 '17 at 19:06
  • Ah I see, it isn't installing either when you specify them yourself. However, you can force the installation using the `-f` or `--force` flag :) I updated the answer. – Frank van Wijk Feb 22 '17 at 19:12
  • Ahhh! that seems to work! PS `7zip-bin` does the auto-resolve of the dependent packages. – jessehouwing Feb 22 '17 at 19:27