155

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
Super Jade
  • 5,609
  • 7
  • 39
  • 61
Aishwary Tiwari
  • 1,643
  • 2
  • 10
  • 12
  • 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 '16 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](https://en.wikipedia.org/wiki/Darwin_(operating_system)) and you are on win32 – Dave V Oct 24 '16 at 20:45
  • its a grunt project, after running this command "npm install -g grunt-cli", i try to run npm install when i get this warning, – Aishwary Tiwari Oct 25 '16 at 18:39
  • 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 '16 at 08:54
  • 1
    There is a pull request that fixes the problem: https://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 '18 at 12:58
  • Simply add `"optionalDependencies": { "fsevents": "*" }` to the package.json file, then use `--no-optional` flag like `npm install --no-optional`. – irandoust Apr 19 '20 at 16:56
  • 1
    This sure is a lot of people accepting warnings, as if they aren't, what's the word... warning you of a problem. – Andrew Koster May 14 '20 at 08:56

5 Answers5

183

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

Alastair Maw
  • 5,373
  • 1
  • 38
  • 50
piotr.d
  • 2,636
  • 2
  • 23
  • 21
  • 48
    Isn't something that is optional and is dependent contradicting itself? – Martijn Burger Oct 23 '17 at 09: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 '17 at 13:12
  • 2
    Absolutely. Hardest thing in SW Development. But if it was a conditional dependency, it would be logical that if the condition was not met, it would not generate the warning as it does now. – Martijn Burger Oct 23 '17 at 15:49
  • 12
    npm install --no-optional – suiwenfeng Jan 11 '18 at 17:56
  • 4
    _"It's only a warning"_ creates a culture of risky complacency. I've witnessed serious production bugs that directly resulted from continually ignoring warnings. – Dem Pilafian Jun 05 '18 at 22:43
  • 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 06 '18 at 10:12
  • 38
    Good answer, now how do I get rid of it? – TetraDev Jul 21 '18 at 21:54
  • 2
    Really annoying. That makes every developer on Windows question their code or settings. Why should do I care Mac-OS warnings when I code on Windows. It's a development dependencies (?), not a runtime dependency. – Jiping Jul 19 '19 at 13:57
  • npm install --no-optional by @suiwenfeng works like a charm. Thanks, – Michael Qin Jul 30 '19 at 00:52
  • @TetraDev use yarn instead (or use a Mac I guess.) – Jonathan Baldwin Feb 06 '20 at 20:45
  • npm cli devs claim this been fixed in NPM v7: https://github.com/npm/cli/pull/169 – KTCO Aug 07 '20 at 02:21
  • Just be aware that npm@7 is still in beta. – piotr.d Aug 12 '20 at 10:28
40

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!

nickl-
  • 8,417
  • 4
  • 42
  • 56
  • 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 04 '19 at 08:42
  • 12
    This cannot be a solution since using package-lock.json is a good thing and this solution suggests the opposite. – ismailarilik Jan 18 '19 at 05:40
  • @ismailarilik This solution allows me to install packages so that I can go on with my work. – nickl- Jun 05 '19 at 04: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`: https://github.com/angular/angular/issues/13935 – FoggyDay Oct 14 '19 at 16:19
28

Using parameter --force:

npm i -f
JeFF - JXG
  • 517
  • 5
  • 7
  • 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 '19 at 09: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 '20 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. – JoeCool Jun 19 '20 at 09:21
  • This should be the accepted answer. Run with force once and it's fixed forever – Johan van den Broek Sep 17 '20 at 09:29
1

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

"optionalDependencies": {
    "fsevents": "^2.3.2"
}
rMonteiro
  • 1,371
  • 1
  • 14
  • 37
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.

Super Jade
  • 5,609
  • 7
  • 39
  • 61