154

I'm trying to run this project. After updating minimatch version to 3.10.9, I'm getting the following error:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\webpack\node_modules\watchpack\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.14: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})

My configuration:

Node v - 4.4.2
npm v - 3.10.9
32 bit windows OS
7
  • 1
    Doesn't sound like an error to me - are you having trouble running the code despite this? npm WARN is just that - a warning that might be worth paying attention to, but didn't actually break anything.
    – Aurora0001
    Oct 24, 2016 at 20:14
  • 2
    And this particular warning is just telling you that an optional dependency did not install because your platform didn't match it's requirements. In this case it's looking for darwin and you are on win32
    – Dave V
    Oct 24, 2016 at 20:45
  • 1
    @AishwaryTiwari, did you actually get an error, or does the code not work? Warnings are unlikely to be an actual problem, because (as the error message says), it skipped an optional dependency.
    – Aurora0001
    Oct 26, 2016 at 8:54
  • 1
    There is a pull request that fixes the problem: github.com/npm/npm/pull/19198 You can subscribe to that pull request, so you get an update when it will be closed.
    – RiZKiT
    Jan 22, 2018 at 12:58
  • 1
    This sure is a lot of people accepting warnings, as if they aren't, what's the word... warning you of a problem. May 14, 2020 at 8:56

5 Answers 5

182

It's a warning, not an error. It occurs because fsevents is an optional dependency, used only when project is run on macOS environment (the package provides 'Native Access to Mac OS-X FSEvents').

And since you're running your project on Windows, fsevents is skipped as irrelevant.

There is a PR to fix this behaviour here: https://github.com/npm/cli/pull/169

12
  • 47
    Isn't something that is optional and is dependent contradicting itself? Oct 23, 2017 at 9:04
  • 9
    That is more of a theoretical question. Maybe conditional dependency would be better? Naming is hard. I guess it was not easy to find a good name for this case while keeping it concise.
    – piotr.d
    Oct 23, 2017 at 13:12
  • 12
    npm install --no-optional
    – suiwenfeng
    Jan 11, 2018 at 17:56
  • 8
    I totally agree, @DemPilafian. Thus I edited my original response and removed "only". I personally treat warnings like errors, but in this case, IMHO, this should not be logged as a warning, but rather info, as in Windows environment you cannot do anything to make the warning go away.
    – piotr.d
    Jun 6, 2018 at 10:12
  • 37
    Good answer, now how do I get rid of it?
    – TetraDev
    Jul 21, 2018 at 21:54
39

This still appears to be an issue, causing package installations to be aborted with warnings about optional packages not being installed because of "Unsupported platform".

The problem relates to the "shrinkwrap" or package-lock.json which gets persisted after every package manager execution. Subsequent attempts keep failing as this file is referenced instead of package.json.

Adding these options to the npm install command should allow packages to install again.

   --no-optional argument will prevent optional dependencies from being installed.

   --no-shrinkwrap argument, which will ignore an available package lock or
                   shrinkwrap file and use the package.json instead.

   --no-package-lock argument will prevent npm from creating a package-lock.json file.

The complete command looks like this:

    npm install --no-optional --no-shrinkwrap --no-package-lock

nJoy!

4
  • 2
    Is it risky to set the --no-optional-flag for code that works just to get rid of the warning? Why is it not set by default?
    – cederlof
    Jan 4, 2019 at 8:42
  • 12
    This cannot be a solution since using package-lock.json is a good thing and this solution suggests the opposite. Jan 18, 2019 at 5:40
  • @ismailarilik This solution allows me to install packages so that I can go on with my work.
    – nickl-
    Jun 5, 2019 at 4:32
  • 1
    "--no-optional" is a really, really Bad Idea. It's usually OK to ignore the warning. You can also use npm install -f: github.com/angular/angular/issues/13935
    – FoggyDay
    Oct 14, 2019 at 16:19
28

Using parameter --force:

npm i -f
4
  • 2
    I did force the installation once with this command and now when I launch npm install I do not have any warnings thanks !
    – Allenile
    Nov 29, 2019 at 9:54
  • 1
    I got some errors while running that command, but after re-running npm install the warnings were gone! thank you sir
    – ccoutinho
    Mar 14, 2020 at 23:02
  • So you're installing in your project those useless dependencies (in a windows machine) to get out the warnings? If so, I hope tree-shaking getting rid of them at production building. I like the workaround. It gets rid of apple-related stuff on my screen. Jun 19, 2020 at 9:21
  • This should be the accepted answer. Run with force once and it's fixed forever
    – Johan
    Sep 17, 2020 at 9:29
2

This answer worked for me, add this to your package.json

"optionalDependencies": {
    "fsevents": "^2.3.2"
}
0

Unsupported platform for fsevents

The current best solution is upgrading your version of npm, which won't have this warning.

If using a Windows machine, an easy way to upgrade is with the tool Upgrade npm on Windows.

Not the answer you're looking for? Browse other questions tagged or ask your own question.