1

I am familiar with npm start, but I don't know what does the prestart and poststart do exactly. Which script is runned before start (i.e.: pre or post). I wanna know to proper flow of it...?

After doing some research I found prestart is called first than start is called.

MarioG8
  • 5,122
  • 4
  • 13
  • 29
Dhruv Parmar
  • 23
  • 1
  • 5

1 Answers1

1

When we set up our scripts properly then simply running the command npm start will be able to handle all of our needs in the proper order. It's has huge useful for many situations where we need something to happen immediately before or immediately after a primary action.( npm start) Here You have reference.

Example

{
  "scripts": {
    "prestart": "node first.js",
    "start": "node index.js",
    "poststart": "node last.js"
  }
}

prestart starts first before npm start and poststart is fired last.

MarioG8
  • 5,122
  • 4
  • 13
  • 29
  • 1
    In short, we just need to fire `npm start` command, it will execute the `prestart` command and than `start` command and at last `poststart` command. There are also other things like `precompress`, `prebuild`, etc. – Dhruv Parmar Dec 23 '22 at 12:40
  • @DhruvParmar Exactly :-) In short obviously ... – MarioG8 Dec 24 '22 at 09:11