@ledsun blog

無味の味は佳境に入らざればすなわち知れず

crestとバグとpacage.json

MongoDBを外部プログラムから更新するのにREST APIがあると便利です。 Cordazar/crest · GitHubというアプリケーションを試してみました。 バグを踏みましたが、原因がわかりました。そういう話です。

npm installできない

npm install crest

エラーが起こります。

npm ERR! Error: ENOENT, chmod '/Users/shigerunakajima/node_modules/crest/bin/server'

この時点でよく考えればわかったのですが・・・

親切な罠

同じ問題がISSUEに上がっていました。

npm install exits with Error: ENOENT, chmod ... · Issue #1 · Cordazar/crest · GitHub しかもPullReqestまで!

これでインストールできる♪

npm install git+https://github.com/jasonnathan/crest.git

しかし・・・通らない!!! 同じエラーが起こります。

npm ERR! Error: ENOENT, chmod '/Users/shigerunakajima/node_modules/crest/bin/server'

バグは

冷静にエラーメッセージを見ます。 見つからずにエラーになっているファイルはserverです。 私が使いたいコマンドはcrestでした。

package.jsonを見てみましょう。

  "bin": {
    "server": "./bin/server"
  }

実行ファイルとして./bin/serverが指定されています。 binディレクトリに入っているのはcrestです。

確認

forkして、package.jsonを直します。

  "bin":  "./bin/crest"

インストールしてみましょう。

npm uninstall git+ssh://git@github.com:ledsun/crest.git

無事にインストールできました。

node_modules/crest/bin/crest
crest listening at http://0.0.0.0:3500

起動もできました!

参考

package.jsonの書き方はこちら。 npm package.json 日本語版 取扱説明書