如何在 Ubuntu 上检查和更改 Nodejs 版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45632508/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to check and change the Nodejs version on Ubuntu?
提问by Headmaster
I am using Ubuntu Linux.
我正在使用 Ubuntu Linux。
How can I check current nodejsversion? I guess, I have 6 version, but I am not sure.
如何查看当前nodejs版本?我想,我有 6 个版本,但我不确定。
And is there way to change it, because I need 4 version. Can some one give step by step commands?
有没有办法改变它,因为我需要 4 个版本。有人可以给出一步一步的命令吗?
回答by James
回答by Pavan Vora
You can check your current NodeJS version by using command node -v. And changing your version can be done by using node version manager. The easiest way to do that is by running this $ npm install -g nnow you can change your current NodeJS version using n (version)e.g. n 4.0.0.
您可以使用命令node -v检查当前的 NodeJS 版本。并且可以通过使用节点版本管理器来更改您的版本。最简单的方法是运行这个$ npm install -gn现在你可以使用n(版本)更改当前的NodeJS版本,例如 n 4.0.0。
node -v
npm install -g n
n 4.0.0
回答by Himanshu
Just type npm versionin your command line and it will display all the version details about node, npm, v8 engine etc.
只需npm version在命令行中输入,它就会显示有关 node、npm、v8 引擎等的所有版本详细信息。

