57

It seems that more recent versions of npm now produce:

enter image description here

I rely on my Linux (Ubuntu) package manager to make decisions about when to update node and npm. Is there a way to turn this check off?

npm config ls -l seems to have nothing related to this and in .npm in my home dir there appears to be no preferences file.

6 Answers 6

67

To disable notifier just run:

npm config set update-notifier false

As Dem Pilafian mentioned - it will add update-notifier=false to ~/.npmrc

To see the current value you need this line

npm config get update-notifier

Read more about npm config here https://docs.npmjs.com/cli/config

4
  • Is it known whether this or other solutions disable npm checking for updates entirely? I don't mind (and would actually welcome) if it checks when I explicitly run npm, but I definitely object to it randomly phoning home whenever I open a terminal.
    – Kev
    Feb 25, 2021 at 7:54
  • @Kev Not sure about that, but npm config edit --global opens the config file in an editor.
    – vovchisko
    Mar 9, 2021 at 11:17
  • 1
    To my surprise, the npm config set update-notifier false command creates the .npmrc if it has not existed yet. So you do not have to search for the file to edit it yourself; it will be created for you.
    – Vojta F
    Apr 27, 2021 at 8:34
  • The fun part is that running npm config ... or any other npm command for the first time will show "npm notice" so to avoid it in the first place one can do echo "update-notifier=false" >> ~/.npmrc instead
    – iamolegga
    Mar 23 at 16:48
26

This was annoying me as well, but there's absolutely no information about it anywhere.

Looking through the code, I've found that the update-notifier-module used by npm has actually a couple of ways to turn it off.

The best one is probably the special config-file located at ~/.config/configstore/update-notifier-npm.json (just search for update-notifier-npm.json). Inside it, simply set "optOut" to true.

The other ways to disable it would be setting an environment-variable called "NO_UPDATE_NOTIFIER" or using the argument "--no-update-notifier"

2
  • 1
    Putting this here for reference npmjs.com/package/update-notifier#user-settings
    – Andrew
    Jul 10, 2019 at 16:40
  • NO_UPDATE_NOTIFIER doesn't seem to cut it, any more (npm 7.19, 7.20.3) though the docs linked to by Andrew show it should. --no-update-notifier works, but note that it doesn't cover inner npm tasks you might call from within the package.json.
    – akauppi
    Aug 16, 2021 at 11:47
16

update-notifier=false

in .npmrc file seems to do the trick since NPM v6.2.0-next.0 (2018-06-28).

2
  • 9
    The command $ npm config set update-notifier false will add the line update-notifier=false to ~/.npmrc for you. Feb 23, 2019 at 2:30
  • 1
    Thank you @DemPilafian for the solution that is both easy and sensible.
    – ThaJay
    Nov 18, 2019 at 17:47
6

For newer (v7+) npm you can use export NPM_CONFIG_UPDATE_NOTIFIER=false to disable via environment

https://github.com/npm/cli/pull/1632

1
  • 1
    NPM_CONFIG_UPDATE_NOTIFIER=false works. Oct 25, 2022 at 15:34
1

if you are to parse the npm command output, one option is to format the output, such as "--json true", "npm list --json true", npm will honour the argument and hide the upgrade message.

0
-1

I created an ansible task that sets optOut to true and lastUpdateCheck to the current date.

In tasks/main.yml:

---

- name: copy update-notifier-npm template file to disable checking for npm updates
  template: src=update-notifier-npm.j2 dest=~/.config/configstore/update-notifier-npm.json

In templates/update-notifier-npm.j2:

{
    "optOut": true,
    "lastUpdateCheck": {{ ansible_date_time.epoch }}000
}

The logic that creates this file in the update-notifier package is here:

https://github.com/yeoman/update-notifier/blob/3fdb21876aa391f9bc7dc35b7d81151677fb533d/index.js#L53

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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