`npm ci` treats optionalDependency with unsupported platform differently than `npm install`

(OJ) #1

When you have platform-specific optional dependencies, npm install does ignore to install those dependencies on unsupported platform, with messages like below:

optional SKIPPING OPTIONAL DEPENDENCY: @nodert-win10-au/windows.applicationmodel@0.2.96 (node_modules/@nodert-win10-au/windows.applicationmodel):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @nodert-win10-au/windows.applicationmodel@0.2.96: wanted {"os":"win32","arch":"any"} (current: {"os":"linux","arch":"x64"})

But in case of npm ci, it doesn’t honor optional dep’s platform but try to install it and fails instead. What makes this differences when using same package-lock, and is there recommended way to achieve same behavior to npm install? Above has tested against npm cli @6.3.0.

Test repo is created at https://github.com/kwonoj/npm-ci-test/pull/1, job using npm install is https://travis-ci.com/kwonoj/npm-ci-test/jobs/138182554 , other job does npm ci is https://travis-ci.com/kwonoj/npm-ci-test/jobs/138182555 which shows described behavior above.

(system) #2

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.