help icon indicating copy to clipboard operation
help copied to clipboard

platform specific dependencies

Open Master-Guy opened this issue 2 years ago • 2 comments

Details

Currently I'm writing an app on Windows, but testing it also on Debian and Ubuntu. To improve ease of access to logs, I wanted to see if I could implement systemd-journald logging. When trying to run npm i systemd-journald I was met with an error telling me that I was running on a wrong platform, which is correct as my development environment is on Windows.

Now I know how to check if the module is available, but how do I tweak package.json in such a way that it will try to install this requirement only on linux platforms? (process.platform === 'linux')

Node.js version

npm 8.7.0 node 16.14.1

Operating system

Windows/Linux

Scope

Installation and runtime

Module and version

systemd-journald

npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"linux"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS:    linux
npm ERR! notsup Valid Arch:  undefined
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: x64

Master-Guy avatar Aug 02 '22 06:08 Master-Guy

I found guidance for this in these links:

  • https://twitter.com/support_npm/status/968195526989512705
  • https://stackoverflow.com/questions/15176082/npm-package-json-os-specific-dependency

vivganes avatar Aug 11 '22 18:08 vivganes

Thank you, will try this next week! I'll reply my findings. Unfortunately it seems the "OS" tag only works to specify on which platforms your app can be used, not for the dependencies, but the "OptionalDependencies" seems to be promising.

Master-Guy avatar Aug 12 '22 14:08 Master-Guy

There has been no activity on this issue for 11 months. The help repository works best when sustained engagement moves conversation forward. The issue will be closed in 1 month. If you are still experiencing this issue on the latest supported versions of Node.js, please leave a comment.

github-actions[bot] avatar Nov 29 '23 01:11 github-actions[bot]

Closing after no activity on this issue for 12 months.

github-actions[bot] avatar Dec 30 '23 01:12 github-actions[bot]