1

Many questions such as this one talk about this very annoying behavior on non-mac OS.

When I run npm install I want to remain aware of any warnings, but in Windows or Linux I would get this:

$ ./npm install
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/watchpack-chokidar2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/webpack-dev-server/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/laravel-mix/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN bootstrap@4.5.0 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.

added 279 packages from 165 contributors, removed 4 packages, updated 2 packages and audited 1978 packages in 27.632s

Notice that most WARN are caused by fsevents which is not available outside of macOS.

Some suggest to hide every warnings with:

npm --logevel=error install

Others advise to use:

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

But all these methods does not seem right to me. I only want to execute npm install and have a configuration file that would hide all optional dependencies that are not available on my operating system.

How can I do that?

nowox
  • 25,978
  • 39
  • 143
  • 293
  • see: https://github.com/npm/npm/issues/20639 "It's not an issue, it's just a warning." – Luuk Jul 26 '20 at 09:08
  • @Luuk I don't see any solution there... That said a `warning` is still a warning and deserve care. When real warnings are hidden into false warnings this is a bad smell – nowox Jul 26 '20 at 09:09
  • You can set options like `optional=false` in your `npmrc` file – Luuk Jul 26 '20 at 09:22
  • @Luuk Indeed, but it will stop warning me about ALL optionals... – nowox Jul 26 '20 at 09:23
  • This question is better discussed here: https://github.com/npm/cli/pull/169 , because that's the place where they can do something about this behavior. – Luuk Jul 26 '20 at 09:35

1 Answers1

2

npm install --no-optional prevents this warning.

radrow
  • 6,419
  • 4
  • 26
  • 53
mohamed ibrahim
  • 567
  • 4
  • 12