Install `libudev-dev` before `yarn install`?

Our product depends on usb-detection, which needs libudev.h to compile its native module.

The libudev-dev package is not installed on the Netlify image. sudo is disallowed.

I also cannot download it and unpack without sudo, because the very first thing that Netlify runs is yarn install, even though I configure another build.command in my netlify.toml.

I don’t see a solution to this situation, can someone help?

I see this package is available on Homebrew: libusb — Homebrew Formulae. Maybe you can try installing it using that?

You can do so by creating a Brewfile.netlify file next to your package.json and add the following to it:

brew 'libusb'
1 Like

Awesome, that worked! I didn’t know you can use a Brewfile. I also had to set these in netlify.toml for gcc called by node-gyp to pick them up:

[build.environment]
CXXFLAGS = "-I/home/linuxbrew/.linuxbrew/include"
LDFLAGS = "-L/home/linuxbrew/.linuxbrew/lib"

The package for libudev-dev is systemd, but I needed both systemd and libusb.