LoginSignup
1

More than 5 years have passed since last update.

package.json を解析してnpm install & npm link する

Last updated at Posted at 2014-07-01

毎回同じmoduleばかり重複してインストールされるのが、容量の無駄だと思ったので、グローバルにインストールして、リンクするようにした。

jq

jq公式サイト

$ brew install jq
npm-link.sh
#!/bin/sh

for i in `cat package.json | jq '.devDependencies | keys | .[]'`;
do
`echo npm install -g $i | sed -e 's/"//g'`;
`echo npm link $i | sed -e 's/"//g'`;
done

もっと良い書き方があるのかもしれないけど、とりあえず動くのでよし。

$ ./npm-link.sh
/path-to-local_node_modules/node_modules/grunt -> /path-to-global_node_modules/node_modules/grunt
...

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
1