help
help copied to clipboard
platform specific dependencies
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
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
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.
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.
Closing after no activity on this issue for 12 months.