25

I hate warnings.

Especially when those warnings are completely ignorable.

Most warnings I encounter are non-clean code warnings and I like to have my code clean. Other warning are actual errors.

Sometimes I miss error warnings because they were "hidden" between other warnings.

So I like to keep things clean.

Thus when I do npm install and see this:

[folatt@MyComputer ~]$ npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

up to date in 33.232s

I want to get rid of that warning.

I know of the --no-optional argument, but that seems hacky to me as well. Isn't there anything one can do in package.json to get rid of this warning?

Folaht
  • 1,053
  • 1
  • 13
  • 32
  • 3
    I am having the exact same warning for ages now - would really appreciate a way on how to get rid of these. – mitschmidt Jan 10 '19 at 09:30
  • 2
    +1 here - struggling with this. I know that npm i -f works. But I don't want to use this. I just want to remove all fsevents warnings... – Deunz Mar 12 '19 at 15:04
  • 1
    This has not yet been released by npm. Reference: https://github.com/npm/cli/pull/169#issuecomment-667304732 – Kunal Kukreja Aug 16 '20 at 11:54

3 Answers3

1

This has been fixed in npm v7. If you update your npm, you shouldn't see these unactionable warnings anymore.

On this GitHub question, someone confirmed that the fsevents skipping optional dependency warnings have been removed in npm v7:

Yep, it’s fixed in v7.

(source)

Shane Bishop
  • 3,905
  • 4
  • 17
  • 47
-3

You should be able to silence those messages with environment values.

npm_config_loglevel=silent

Default: “notice”

Values: “silent”, “error”, “warn”, “notice”, “http”, “timing”, “info”, “verbose”, “silly”

Details here; https://docs.npmjs.com/misc/config#loglevel

siniradam
  • 2,727
  • 26
  • 37
  • But that will silence all other warnings and messages too. – OrangeDog Sep 03 '20 at 06:56
  • @OrangeDog unfortunately yes. But it doesn't have to be silent of course. Setting to "error" will still provide sufficient messages. I don't see any other way for this case. – siniradam Sep 05 '20 at 03:05
-6

You can use npm audit fix command. Also if you could share your package.json file that will be helpful

Sachin
  • 1
  • 2
  • 1
    No, that has no effect on these warnings, which happen on a PC because the optional dependency is for Apple stuff. – philw Mar 25 '20 at 14:21
  • ```npm audit fix``` is used for a different thing. It will fix possible security vulnerabilities. The question is about optional dependencies warnings during installation. – Anastasiia Solop Sep 28 '20 at 10:48