Snap build process fails when it hits MacOS specific node modules

Hi there.

I’m having trouble getting my Electron app build recently. This is my snapcraft.yml: https://github.com/ransome1/sleek/blob/master/snap/snapcraft.yaml

The build process fails with this:

Building sleek 
+ [ -n http://10.10.10.1:8222/ ]
+ export ELECTRON_GET_USE_PROXY=1
+ export GLOBAL_AGENT_HTTP_PROXY=http://10.10.10.1:8222/
+ export GLOBAL_AGENT_HTTPS_PROXY=http://10.10.10.1:8222/
+ npm install
[08/Apr/2021:06:04:42 +0000] "CONNECT registry.npmjs.org:443 HTTP/1.1" 200 35744 "-" "-"
[08/Apr/2021:06:04:43 +0000] "CONNECT registry.npmjs.org:443 HTTP/1.1" 200 29648 "-" "-"
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for dmg-license@1.0.8: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  any
npm ERR! notsup Actual OS:   linux
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-04-08T06_04_43_608Z-debug.log
Failed to run 'override-build': Exit code was 1.
Build failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/lpbuildd/target/build_snap.py", line 257, in run
    self.pull()
  File "/usr/lib/python3/dist-packages/lpbuildd/target/build_snap.py", line 223, in pull
    env=env)
  File "/usr/lib/python3/dist-packages/lpbuildd/target/build_snap.py", line 100, in run_build_command
    return self.backend.run(args, env=full_env, **kwargs)
  File "/usr/lib/python3/dist-packages/lpbuildd/target/lxd.py", line 537, in run
    subprocess.check_call(cmd, **kwargs)
  File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['lxc', 'exec', 'lp-bionic-amd64', '--env', 'LANG=C.UTF-8', '--env', 'SHELL=/bin/sh', '--env', 'SNAPCRAFT_LOCAL_SOURCES=1', '--env', 'SNAPCRAFT_SETUP_CORE=1', '--env', 'SNAPCRAFT_BUILD_INFO=1', '--env', 'SNAPCRAFT_IMAGE_INFO={"build-request-id": "lp-63057569", "build-request-timestamp": "2021-04-08T05:59:12Z", "build_url": "https://launchpad.net/~build.snapcraft.io/+snap/0bd466522b32144f4aca7878faa1937b/+build/1366043"}', '--env', 'SNAPCRAFT_BUILD_ENVIRONMENT=host', '--env', 'http_proxy=http://10.10.10.1:8222/', '--env', 'https_proxy=http://10.10.10.1:8222/', '--env', 'GIT_PROXY_COMMAND=/usr/local/bin/snap-git-proxy', '--', '/bin/sh', '-c', 'cd /build/sleek && linux64 snapcraft pull']' returned non-zero exit status 2.
Revoking proxy token...
RUN: /usr/share/launchpad-buildd/bin/in-target scan-for-processes --backend=lxd --series=bionic --arch=amd64 SNAPBUILD-1366043
Scanning for processes to kill in build SNAPBUILD-1366043

The whole log is here: https://launchpadlibrarian.net/532431681/buildlog_snap_ubuntu_bionic_amd64_0bd466522b32144f4aca7878faa1937b_BUILDING.txt.gz

So apparently my app needs a module called “dmg-license” in order to build the MacOS dmg file by the Github CI process. Which works fine.

But when the Snapcraft build process tries to process the module it fails, as it is not supported for being processed in the Linux VM, which I understand. But as the Snapcraft build process does not need the module, is there a way to exclude these MacOS specific modules from being part of the Snapcraft build process?

Or in other words: How do I get my Snaps build again, it worked until recently.

Any help is appreciated!

You probably want something like this https://docs.npmjs.com/cli/v7/configuring-npm/package-json#os in your package.json