Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for cross platform projects #64

Open
koraniar opened this issue Sep 4, 2023 · 3 comments
Open

Support for cross platform projects #64

koraniar opened this issue Sep 4, 2023 · 3 comments

Comments

@koraniar
Copy link

koraniar commented Sep 4, 2023

I am developing an application that is prepared to work on Windows, Mac, and Linux with the same code, of course, Mac requests permissions that do not exist in the other operating systems and that is why I am using this library.

However, when I try to run npm install on the project on a Windows or a Linux device, there is an error saying that this library is incompatible:

C:\GitHub\cross>npm install
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  undefined
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Koraniar\AppData\Local\npm-cache\_logs\2023-09-04T21_41_03_261Z-debug-0.log

I know I can force the installation using npm install --force, but there are some side effects I would like to avoid like having version conflicts, bypassing security vulnerabilities, etc.

Is there a way to allow this library to be installed in different operating systems? Like allowing it to be installed and do nothing once it is imported If the platform is not darwin like mac-screen-capture-permissions.

@KishanBagaria
Copy link
Contributor

You can try moving it to optionalDependencies.

@koraniar
Copy link
Author

@KishanBagaria thank you for your answer, it works perfectly to avoid having the error on not compatible operating systems.

However, it forces me to use a Mac device in the CI server to do unit testing and compile the final binaries, which typically is more expensive than a Linux device (even in some plans the Linux devices are free but not the Macs).

Is there any other way to allow this library to be downloaded on a Linux device to create Mac builds?

@KishanBagaria
Copy link
Contributor

Cross-compilation or prebuilds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants