angularjsnpmnpm-scriptsnpm-startangular-seed

Prestart and pretest script in angular seed project


I am using angular seed project as a skeleton for my angularjs app. The package.json contains two scripts-

  1. prestart and
  2. pretest

Both run npm install when I run the server with the npm start command.

I don't want to install packages whenever I start the server. However, if I want to update my dependencies, then I can use update-deps.

Are these scripts mandatory to use, or we can omit them? Will they have any consequences if I remove them? If yes, then what?


Solution

  • If you are running npm install manually and nothing is removing/modifying node_modules or package*.json in the lifecycle, then those pretest and prestart scripts (that do npm install and nothing else) can be omitted.

    If you are 100% sure that you do not want or need lifecycle scripts like prestart/poststart and pretest/posttest but don't want to modify the package.json for any reason, you can use --ignore-scripts:

    npm --ignore-scripts test
    

    It seems that those lifecycle scripts are there just as a convenience for those who run npm start or npm test without running npm install first. They can be safely removed.