8

In NPM3, if a package (re)installed a local dependency (e.g. npm i file:../some-dep), and that dependency package had a prepublish script, then it would be automatically run. This was rather useful in the instance you were developing a small tree of modules requiring transpilation, as I am; simply re-installing the local dependency in its parent executed the transcompilation (and updated the compiled code) without any additional steps.

Apparently with NPM 5 (and presumably NPM 4), this behaviour has been silently dropped; nothing in the release notes AFAICT.

I am well-aware that publish was split into prepublish and prepare, however none of them do anything in the above context.

Has this behaviour really been unceremoniously dropped? Is it a bug? Feature-removal?

Gav
  • 103
  • 1
  • 4
  • It is well documented in [npm doc](https://docs.npmjs.com/misc/scripts#deprecation-note) `Since npm@1.1.71, the npm CLI has run the prepublish script for both npm publish and npm install, because it's a convenient way to prepare a package for use (some common use cases are described in the section below). It has also turned out to be, in practice, very confusing. As of npm@4.0.0, a new event has been introduced, prepare, that preserves this existing behavior.` – Gabriel Bleu Oct 25 '17 at 08:07
  • `npm install` in the *root package*, which will run the `prepare` script in NPM4/5. That's not what this question refers to. – Gav Oct 25 '17 at 08:20
  • Ho you are using multi-package repo ? Maybe [lerna bootstrap](https://github.com/lerna/lerna#bootstrap) could help ? – Gabriel Bleu Oct 25 '17 at 11:41
  • It's not a multi-package repo. Indeed for the purposes of this question, there are no repos, just a few directories with `package.json`s in them which reference each other through having dependency packages of the form `file:../some-dep`, (see the answer [here](https://stackoverflow.com/questions/15806241/how-to-specify-local-modules-as-npm-package-dependencies) ) – Gav Oct 25 '17 at 14:48
  • Have the same issue, prepare and prepublish are both not running (for modules on my npm instance, not even local). For one package they are and it's literally a copy and paste almost of the ones which are not working :/ – Dominic Mar 14 '18 at 10:15

0 Answers0