LoginSignup
13
5

More than 5 years have passed since last update.

npm prepublishOnlyでビルドを呼んではいけない

Last updated at Posted at 2017-09-14

2018/02/06 追記

以下の記事にpublish時の挙動について詳しくまとまっています。適宜参照するとよいです。

npm prepublish の現状と今後どう変わっていくかを、表にしてまとめた - Qiita


install時にprepublishに書いたbuildが走るのが嫌で、publishのみ実行されるprepublishOnlyを使っていました。
しかし、これは大きな間違いです。

npmの開発者の一人であるiarnaのコメントを抜粋します。

"I want to do build steps that are neccessary to use my module." — use prepare
"I want to do validation steps that stop me from publishing bad code." — use prepublishOnly

prepublishOnlyはアップデートのためのtarbal生成後に実行されるので、意味がありません。

prepareを使うようにしましょう。
また、npm5からは、prepublishの挙動は、prepublishOnlyと同じになるので注意が必要です。

13
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
5