14

When I run various npm commands, the console output is filled with ads for various projects and people. I'm a prolific open source contributor, but console output for a tool is not a good place for advertising.

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

...
...

Thank you for using husky!
If you rely on this package, please consider supporting our open collective:
> https://opencollective.com/husky/donate

That's around 11 lines of output, colorised to grab my attention, when I'm looking for warnings or errors.

How do I block ads in npm?

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
  • 1
    I don't know the answer but have some good news for you https://www.infoq.com/news/2019/08/npm-bans-package-ads/ – Parth Raval Mar 17 '20 at 13:03
  • Since that mechanism is supposed to be used for any possibly relevant message or warning and there's no specific "ads" type message, you can either block all output (maybe not a good idea) or try to get the package author to remove that arguably annoying message, like any other unnecessary code. – deceze Mar 17 '20 at 13:04
  • 1
    I don't think there's anything native that would work for all NPM packages, NPM has banned this practice so maybe just report them? – Ryan McDonough Mar 17 '20 at 13:05
  • https://docs.npmjs.com/misc/config#loglevel – str Mar 17 '20 at 13:06
  • 3
    How did somebody vote to close this as opinion-based? – Jared Smith Mar 17 '20 at 14:54
  • 2
    @ParthRaval The packages (and the OPEN_SOURCE_CONTRIBUTOR environment variable mentioned) mentioned in your article would make for a good answer. – mikemaccana Mar 17 '20 at 15:10
  • 1
    @ParthRaval - ditto what _@mikemaccana_ suggests. You should change your comment into a formal answer. Even if you just quote the last two paragraphs from [here](https://www.npmjs.com/package/funding#how-can-i-disable-this) it would suffice as a good answer. – RobC Mar 18 '20 at 09:46
  • 1
    @RobC & `@mikemaccana`, Thank you, brothers, for your support & help. – Parth Raval Mar 18 '20 at 11:04
  • MSFT has started doing this in the console window for VS Code too when using older versions of languages like PowerShell. Very annoying. – TylerH Mar 19 '20 at 15:53
  • related: https://stackoverflow.com/questions/58972251/what-does-x-packages-are-looking-for-funding-mean-when-running-npm-install – gman Aug 26 '20 at 09:36

2 Answers2

6

You can remove ads using the funding package by adding an environment variable:

OPEN_SOURCE_CONTRIBUTOR=true

Some packages that use opencollective-postinstall need their own command instead:

DISABLE_OPENCOLLECTIVE=true
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
Parth Raval
  • 4,097
  • 3
  • 23
  • 36
0

for the opencollective

OPENCOLLECTIVE_HIDE=true

did the trick for me, more optins see https://github.com/nuxt/opencollective#disable-message for more disabling options

kaznovac
  • 1,303
  • 15
  • 23