LoginSignup
19
14

More than 1 year has passed since last update.

yarn ではなく npm install を叩いたらエラーを出したいを実現する方法が簡単だった

Last updated at Posted at 2021-09-23

やりたいこと

yarn ではなく npm install を叩いたらエラーを出す仕組みを作りたい

実現方法

  • npmrc に engine-strict=true を記載する
  • npmrc とは npmの設定ファイル のことである
// .npmrc
engine-strict=true
  • package.jsonの engines を設定する
package.json
"engines": {
  "npm": "npmではなくyarnを使用してください"
}

2つの設定を完了させた上でnpm installと叩いてみる

npm install コマンドを叩いた結果
npm-error.png

これでyarnを使用しているプロジェクトで
間違ってnpm installを叩いてしまっても大丈夫ですね!

参考文献

19
14
0

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
19
14