[npm & Bower] npm run-script 実行時の npm ERR! を非表示にしたい
オプションを付けて実行するか、.npmrc に設定を書く。
[markdown]
## 症状
lint を実行したけれど、npm ERR! があって可読性が落ちる。
“`prettyprinted
% npm run-script lint
> bp-middleman@0.2.5 lint /Users/****/projects/bp-middleman
> npm run lint:css && npm run lint:html && npm run lint:js
> bp-middleman@0.2.5 lint:css /Users/****/projects/bp-middleman
> bundle exec scss-lint
source/stylesheets/foundations/_typography.scss:233 [W] ColorVariable: Color literals like `#eee` should only be used in variable declarations; they should be referred to via variable everywhere else.
source/stylesheets/foundations/_typography.scss:244 [W] ColorVariable: Color literals like `#ccc` should only be used in variable declarations; they should be referred to via variable everywhere else.
npm ERR! Darwin 15.4.0
npm ERR! argv “/usr/local/Cellar/node/6.1.0/bin/node” “/usr/local/bin/npm” “run” “lint:css”
npm ERR! node v6.1.0
npm ERR! npm v3.8.6
npm ERR! code ELIFECYCLE
:
“`
## 対応
> * [node.js – How to suppress output when running npm scripts – Stack Overflow](http://stackoverflow.com/questions/34426332/how-to-suppress-output-when-running-npm-scripts)
CLI からの実行時に `-s, –silent: –loglevel silent` オプションを付ける。
“`prettyprinted
% npm run-script –silent lint
source/stylesheets/foundations/_typography.scss:233 [W] ColorVariable: Color literals like `#eee` should only be used in variable declarations; they should be referred to via variable everywhere else.
source/stylesheets/foundations/_typography.scss:244 [W] ColorVariable: Color literals like `#ccc` should only be used in variable declarations; they should be referred to via variable everywhere else.
“`
`.npmrc` に設定する場合。`-s` オプションなしで同じ振る舞いとなる。
“`:~/.npmrc
loglevel=silent
“`
> * [npmrc | npm Documentation](https://docs.npmjs.com/files/npmrc)
> * [config | npm Documentation](https://docs.npmjs.com/misc/config)
[/markdown]