如何检查Node JS是否安装正确?

问题描述 投票:0回答:3

我对 OSX 完全陌生。我尝试按照分步教程使用终端安装 Node JS。如何检查 Node JS 是否安装成功?是否有相当于 Windows 中“程序和功能”的命令或 GUI 界面?

谢谢, DV

javascript node.js macos
3个回答
2
投票

在终端中输入

node -v
,如果安装正确,您应该会看到显示的节点版本。


0
投票

node.js 可执行文件(二进制)应该是node,而不是nodejs。然而, 某些 Linux 发行版(例如 Ubuntu)上存在命名冲突, 导致可执行文件安装为nodejs。从 Ubuntu 开始 例如,14.04 apt-get install nodejs 还将安装可执行节点(作为 Nodejs 的符号链接实现)。换句话说: 为了保持一致性,请先尝试 node -v。

$ 节点-v

如果使用了符号链接

$nodejs -v


0
投票

要检查漏洞,您可以使用

is-my-node-ok

只需在终端上输入:

npx is-my-node-ok

输出 - 当不易受到攻击时

$ node -v
v20.17.0
$ npx is-my-node-ok

All good :)

输出 - 寿命结束时

$ node -v
v15.14.0
$ npx is-my-node-ok

Danger


v15.14.0 is end-of-life. There are high chances of being vulnerable. Please upgrade it.

输出 - 当脆弱时

$ node -v
v20.3.0
$ npx is-my-node-ok

Danger

The current Node.js version (v20.3.0) is vulnerable to the following CVEs:

CVE-2023-30581: The use of proto in process.mainModule.proto.require() can bypass the policy mechanism and require modules outside of the policy.json definition
Patched versions: ^16.20.1 || ^18.16.1 || ^20.3.1
==================================================================================================================================================================================
© www.soinside.com 2019 - 2024. All rights reserved.