node.js - 如何在 bash 中抑制 npm WARN 弃用消息

标签 node.js linux bash npm

我在 Linux Mint 18.0 中安装了多个版本的 node.js。我使用 nvm 管理它们。由于项目依赖性,我需要将版本 0.10 作为默认版本 (nvm use 0.10)。因此,每次启动终端时,我都会得到以下输出:

npm WARN deprecated This version of npm lacks support for important features,
npm WARN deprecated such as scoped packages, offered by the primary npm
npm WARN deprecated registry. Consider upgrading to at least npm@2, if not the
npm WARN deprecated latest stable version. To upgrade to npm@2, run:
npm WARN deprecated 
npm WARN deprecated   npm -g install npm@latest-2
npm WARN deprecated 
npm WARN deprecated To upgrade to the latest stable version, run:
npm WARN deprecated 
npm WARN deprecated   npm -g install npm@latest
npm WARN deprecated 
npm WARN deprecated (Depending on how Node.js was installed on your system, you
npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if
npm WARN deprecated on Windows, run them from an Administrator prompt.)
npm WARN deprecated 
npm WARN deprecated If you're running the version of npm bundled with
npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS
npm WARN deprecated will be bundled with a version of npm@2, which has some small
npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
npm WARN deprecated semver behavior.

如何抑制这些消息?

最佳答案

您可以通过环境变量抑制或安静 NPM:

npm_config_loglevel=silent npm version

这应该在您的 .bashrc 中工作(或在您调用 nvm 的任何地方):

npm_config_loglevel=silent nvm use 0.10

或者你可以全局设置环境变量

export npm_config_loglevel=silent

可以找到不同的日志级别here - 他们是:

"silent", "error", "warn", "http", "info", "verbose", "silly"

关于node.js - 如何在 bash 中抑制 npm WARN 弃用消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38281709/

相关文章:

bash - 如何在 Bash 中运行多个 inotifywait 循环?

javascript - 发送到 CouchDB 时格式不正确的 Json

xml - Node.js - Craigslist 批量发布 api(无法解析 rss)

javascript - 使用 AngularJS 和 Node 更新 mongodb

linux - hive 脚本(hivequery.hql)文件中的这个符号是什么意思 "use ${word:word}"

bash - 假装是任何命令的 bash 中的 tty

node.js - 如何在Socket.IO中一次性离开socket所连接的所有房间

c++ - 运行一个需要输入而不挂起的命令,但仍然允许输入

php - 当我从本地 Homestead 更改为 AWS 中的产品时,Laravel 抛出 SQLite 错误

bash - 在没有输入的情况下运行 bash 脚本