Dev Notes

Fix “Unsupported platform for fsevents” in npm

When trying to install npm packages via “npm install”, you might encounter an error “EBADPLATFORM”

Ramazan Yavuz
Ramazan Yavuz ·

When trying to install npm packages via “npm install”, you might encounter an error “EBADPLATFORM”

npm ERR! notsup Unsupported platform for fsevents@1.1.3: wanted 
{"os":"darwin","arch":"any"}

This Error is indicating that you are installing the fsevents module in another OS rather than Mac, but the fsevents module only works for Mac OS.
If you did not purposefully include fsevents in your package.json, this hints at a sub-dependency.

fsevents is a macOS-specific package. On another platform it should normally be an optional dependency of the package that uses it. Check package.json and the lockfile to find whether it is listed directly or introduced by another package; update or correct that dependency rather than forcing an incompatible native module to install.

npm install --loglevel verbose

Verbose logging helps identify the dependency path. In npm 7, --force removes several safeguards, including platform checks. It does not make a macOS module work on Windows or Linux and is not merely a command to refetch cached files. See the npm 7 configuration reference.

If the package is genuinely optional and you do not need any optional features, npm 7 also supports npm install --omit=optional. This omits all optional dependencies, not just fsevents. It does not fix a dependency that was incorrectly declared as required.

Keep the lockfile change reviewable and use the npm version expected by the project. Deleting the lockfile or using --force without understanding the dependency can hide the cause.


Originally published on blog.yavuz.support: https://blog.yavuz.support/fix-unsupported-platform-for-fsevents-in-npm.