Why isn't 'build' listed on the 'npm-scripts' page?

The npm-scripts page lists the scripts that are implied by other scripts, but ‘build’ isn’t listed and I’m not clear why.

Because it’s not a lifecycle script. npm build is internal npm plumbing, pretty much, not a lifecycle script like test

Thanks for the response. I get what you’re saying. (I assume that’s ‘lifecycle’, not ‘lifestyle’ :slight_smile:) and I did see where it says that ‘npm build’ is for ‘internal plumbing’.

So, that answers my headline question, but I still find this pretty confusing. Mainly because ‘npm build’ is called all the time as part of what I (and most? others) would consider the “lifecycle” of a package (which I’m looking at from a development context). So, to say it’s “internal plumbing” seems to be swimming against the current. Is everyone doing it wrong and we should not be calling ‘npm build’ directly? Should everyone be using ‘npm prepare’?

My best understanding is that NPM uses the term ‘lifecycle’ to talk about black-box operations one would perform on a ‘finished package’. Or maybe better to say that “development” is not part of the lifecycle in the NPM terminology?

Based on this feedback, I’ve searched for a clear definition of what ‘lifecycle’ means in the NPM context, and I haven’t found anything good. Or rather, the explanations I find seem to be at odds with the “internal plumbing” explanation. (Happy to provide examples, but I also feel I’m just “missing something” here.)

“lifecycle” is our terminology for “event hooks”. There is no “script hook” called “build” that happens during npm build, which is why "scripts": "build": {...} doesn’t run anything automatically, and why you need to do npm run build to use a script with that name.

In npm terminology, build is not when things are “prepared” – it’s when bins and manpages are linked, and when install scripts are run. This is pretty different from what web developers would expect, but is what has been there since the dawn of npm itself.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.