npm ERR code EBADPLATFORM Unsupported platform for fsevents

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
4 min

banner

# Table of Contents

  1. npm ERR code EBADPLATFORM Unsupported platform for fsevents
  2. Correct the contents of your package.json file
  3. Delete your node_modules and package-lock.json files
  4. Run the npm install command with the --force option
  5. Try to run npm audit fix
  6. Update your version of npm
  7. Update your package-lock.json file

# npm ERR code EBADPLATFORM Unsupported platform for fsevents

The error "npm ERR! code EBADPLATFORM Unsupported platform for fsevents" occurs when we try to install the fsevents module on an unsupported operating system.

To solve the error, make sure that the package you are trying to install is supported by your operating system, delete your node_modules and reinstall your dependencies.

shell
npm ERR! code EBADPLATFORM npm ERR! notsup Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin"} (current: {"os":"linux","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 ebadplatform unsupported platform for fsevents

The error most commonly occurs with the fsevents and chokidar packages.

The fsevents module provides native access to macOS File System events in Node.js.

The module only supports macOS, so trying to install it on Windows or Linux causes the error.

If you install a package that depends on fsevents while running on Windows or Linux, it will automatically get skipped with the following warning.

  • npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents

The warning occurs because fsevents is an optional dependency that is only installed on macOS computers.

NPM knows to automatically skip the dependency if you aren't on macOS.

If the message is just a warning (and not an error), you can safely ignore it. Usually, NPM knows to not try to install OS-specific packages on not-supported operating systems.

# Correct the contents of your package.json file

Open your package.json file (should be located at the root of your project) and make sure the fsevents module is not in your dependencies or devDependencies objects.

The module should not be in your dependencies and devDependencies objects because trying to run npm install on Windows or Linux would fail.

Instead, if you'd like to specify fsevents as a dependency, use the optionalDependencies object.

package.json
"optionalDependencies": { "fsevents": "^2.3.2" }

using optional dependencies

You can optionally change the version if you need to install a specific version of fsevents.

The optionalDependencies object is used if you'd like npm to proceed if it cannot find the specified dependency or fails to install it.

If the npm install command is run on macOS, then the installation of fsevents will succeed, otherwise, it will simply get skipped.

If you want to skip installing optional dependencies without checking if the installation is successful, set the --omit flag to optional.

shell
npm install --omit=optional

skipping optional dependencies

# Delete your node_modules and package-lock.json files

If the error persists, try to delete your node_modules and package-lock.json (NOT package.json) files.

If you are on Windows, issue the following commands from the root directory of your project (where your package.json file is).

cmd
# Windows rd /s /q "node_modules" del package-lock.json del -f yarn.lock # ๐Ÿ‘‡๏ธ clean npm cache npm cache clean --force npm install

If you are on macOS and Linux, issue the following commands from the root directory of your project.

shell
# macOS and Linux rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # ๐Ÿ‘‡๏ธ clean npm cache npm cache clean --force npm install

Check if the error persists after reinstalling your node modules.

# Run the npm install command with the --force option

If the error persists, try to run the npm install command with the --force option.

shell
npm install --force

npm install with force option

# Try to run npm audit fix

If the error persists, try to run npm audit fix with the --force option.

shell
npm audit fix --force

npm audit fix force

Check your terminal for messages with additional information.

# Update your version of npm

Another thing you can try is to update your version of npm.

shell
npm install -g npm@latest

If you use an older npm version, it might be the cause of the issue.

If you get a permissions error on macOS or Linux, prefix the command with sudo.

shell
# ๐Ÿ‘‡๏ธ If you get a permissions error on macOS / Linux sudo npm install -g npm@latest

If you get a permissions error on Windows, open CMD as an admin.

  1. Click on the Search bar and type CMD.

  2. Right-click on the Command Prompt application and click "Run as administrator".

run cmd as administrator

  1. Rerun the command.
shell
npm install -g npm@latest

# Update your package-lock.json file

If the error persists, open your package-lock.json file.

It is located in the root directory of your project, right next to your package.json file.

Press Ctrl + F and search for "node_modules/fsevents".

Add the wind32 and linux operating systems to the os array.

package-lock.json
"node_modules/fsevents": { // ... rest "os": [ "darwin", "win32", "linux" ], // ... rest }

add operating systems to os array

After adding the operating systems to the os array, try running the npm install command.

shell
npm install

Note: if the issue persists and the message is just a warning (and not an error), you can safely ignore it.

Usually, NPM knows to not try to install OS-specific packages on not-supported operating systems.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2025 Borislav Hadzhiev