微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

node.js-如何在bash中禁止npm WARN弃用的消息

我在Linux Mint 18.0中安装了多个版本的node.js.我使用nvm管理它们.由于项目相关性,我需要将版本0.10作为认版本(nvm使用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”

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐