1

I am installing a typescript module via git. This module has a package.json file that includes a prepare script in its scripts section. However, it appears the prepare script is not executed on npm install <git repository#version>.

How can I have the prepare script executed on npm install via the git repository?

Ari
  • 4,121
  • 8
  • 40
  • 56

1 Answers1

0

The prepare script is not intended to be executed by package consumers, but only by the package owner.

This means you cannot execute the prepare script of any third-party package.

Create a prepare script, that is identical to the third-party package, in your package.json , but it will be executed only on command npm install, not on command npm install '<git repository#version>'

If you publish your own package and you want that prepare script is executed when a consumer installs your package, you have to create a preinstall script instead of a prepare script.

hdorgeval
  • 3,000
  • 8
  • 17
  • 1
    "you have to create a preinstall script instead of a prepare script" -- This is no longer true. Since NPM v5, `prepare` is executed by `npm install`. See the [this answer](https://stackoverflow.com/a/70228570/8910547) and the documentation it links to. See also [this question and its answer](https://stackoverflow.com/questions/44499912/why-is-npm-running-prepare-script-after-npm-install-and-how-can-i-stop-it). – Inigo Apr 07 '22 at 15:57