NPM-RESTART(3)

πŸ“¦ version 1.2.1, in nixos 26.05, nixpkgs unstable

πŸ’… npm-restart(3) β€” like, the whole manual page, bestie

okay so real quick: this is the page for npm-restart, section 3 of the manual. Yes, section 3. Yes, that's a thing. Sit with it. 🫢


✨ NAME ✨

npm-restart β€” restart a package. that's it. that's the whole vibe. πŸ”₯


πŸŽ€ SYNOPSIS πŸŽ€

  npm.commands.restart(packages, callback)

like literally that's the call. packages, then callback. no cap. πŸ’…


🌸 DESCRIPTION 🌸

okay so what this does is it restarts a package β€” and honestly? it'll restart multiple packages too, it's not gonna gatekeep. πŸ‘‘

here's the thing tho, it's not just one script. it runs a package's "stop", "restart", and "start" scripts β€” plus all the associated pre- and post- scripts β€” in this exact order, no improvising:

  1. prerestart
  2. prestop
  3. stop
  4. poststop
  5. restart
  6. prestart
  7. start
  8. poststart
  9. postrestart

nine whole steps. it's giving choreography. 🧚

and if you don't specify a version? it restarts the "active" version. the main character version. ⭐

oh and β€” npm can restart multiple packages, bestie. you just pass multiple packages in the packages parameter. that's it. that's the whole trick. 🌈


πŸ’€ NOTE πŸ’€

heads up, this one matters: the "restart" script gets run in addition to the "stop" and "start" scripts β€” not instead of them. so don't be out here thinking restart replaces stop+start, because it does not. all three show up. 😭

this is the behavior as of npm major version 2. and if this behavior ever changes? it'll come with an increase in the major version number. periodt. πŸ’…


πŸ¦‹ SEE ALSO πŸ¦‹

  • npm apihelp start
  • npm apihelp stop

mwah πŸ’– that's the whole page β€” brought to you by the March 2017 edition, straight out of the npm docs, and rewritten with so much love you'd think it was a text from your bestie at 2am. go restart something. slay. πŸ’œ

πŸ“¦ where this page comes from