Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8862

自作npmコマンドの作成方法

$
0
0

my-npm-commandとかで自作npmコマンドを蹴る方法のメモ

Node.js 12.18.3、npm 6.14.8で確認

手順

  • Node.jsのプロジェクトを作成
    • npm initとか適当に
  • package.jsonに以下を追加
"bin":{"my-npm-command":"./index.js"}
  • Node.jsのCLIを作成
    • 以下はサンプル
index.js
#!/usr/bin/env node
console.log('my-npm-command');
  • npm linkを叩き、my-npm-commandを実行して動いてればOK
    • 外したくなったらnpm unlink

Viewing all articles
Browse latest Browse all 8862

Trending Articles