npm says 'Unsupported platform for fsevents' on Windows or Linux
Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})Short answer
fsevents only works on macOS. Build tools list it as an optional dependency, and npm is allowed to skip an optional package that cannot install, so on Windows or Linux the line is a notice, not the failure. If the install stops, the error is elsewhere in the output. If you list fsevents yourself, move it to optionalDependencies.
Fix it fast
1Find out which cause you have
Find out which package pulls fsevents in, and whether the install finished. The exit code tells you if the warning mattered.
npm ls fsevents npm install; echo "exit code: $?"2Match what you see, then jump to its fix
- 1
npm ls fsevents shows it under a watcher package, and npm install exits with code 0A dependency lists fsevents as optional, so the line is only a noticeFix - 2
npm ls fsevents shows it directly under your project name, and package.json lists itfsevents is in your own dependencies or devDependenciesFix - 3
You maintain a package with native macOS code and see the same text from your own codeYour own package should only be installed on some operating systemsFix
- 1
What does the error look like?
Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
Cause 1 of 3
A dependency lists fsevents as optional, so the line is only a notice
1Check
Optional dependencies that cannot be found or fail to install do not stop the install. The notice itself says fsevents wants the darwin (macOS) platform and your host is something else.
npm ls fsevents
node -p "process.platform"2Fix
Nothing to fix. npm continues without the package. If the line bothers you, skip optional packages.
npm install --omit=optional3Verify
The install ends with exit code 0 and your dev server or build starts.
npm install; echo "exit code: $?"Confirmed by docs.npmjs.com
Cause 2 of 3
fsevents is in your own dependencies or devDependencies
1Check
Only optionalDependencies get the skip-on-failure treatment. A copy you added by hand to dependencies or devDependencies is treated as a normal dependency.
grep -n "fsevents" package.json2Fix
Remove it from dependencies and add it again as an optional dependency, or delete it if no code of yours imports it.
npm uninstall fsevents
npm install --save-optional fsevents3Verify
package.json now shows fsevents under optionalDependencies and the install passes on Windows or Linux.
grep -n -B1 "fsevents" package.json
npm install; echo "exit code: $?"Confirmed by docs.npmjs.com
Cause 3 of 3
Your own package should only be installed on some operating systems
1Check
The os field in package.json restricts a package to the operating systems named in it, taken from process.platform.
grep -n "\"os\"" package.json2Fix
Declare the supported systems in os, and make any consumer list your package under optionalDependencies, so other systems skip it cleanly.
"os": ["darwin"]3Verify
On another system the package is skipped and the host project still installs.
npm install; echo "exit code: $?"Confirmed by docs.npmjs.com
How do I stop it coming back?
- Read the end of the npm output and the exit code before chasing a warning.
- Never add macOS-only packages to dependencies; use optionalDependencies.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
npm install stops while building a native module with node-gyp
Could not find any Python installation to use
node-gyp compiles native add-ons, so it needs a supported Python and a C/C++ compiler.
3 causes, each with a fixBack end
Application Load Balancer returns 502 for a Node.js target
HTTPCode_ELB_502_Count
An ALB returns 502 when the target gives it something it cannot use: a refused or reset connection, a connection closed mid-request, a bad response, or a header over 32 K.
4 causes, each with a fixBack end
corepack enable fails: permission denied while creating the pnpm link
Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'
corepack enable writes small link files for yarn and pnpm next to your node binary.
2 causes, each with a fixBack end
Create React App says Node is too old, and npm will not run on the new one
npm does not support Node.js v10.19.0
The shell is running an old Node.js that is below the version Create React App needs.
3 causes, each with a fixBack end
firebase deploy cannot load your functions: user code failed to load
Functions codebase could not be analyzed successfully. It may have a syntax or runtime error
The Firebase CLI loads your functions code on your machine before it deploys, to learn which functions exist.
4 causes, each with a fixBack end
firebase deploy stops because the predeploy lint step failed
Error: There was an error deploying functions
The predeploy hook in firebase.json runs npm run lint before every deploy, and a failing hook cancels the deploy.
3 causes, each with a fix