简体   繁体   English

在Win10上安装Node.js之后,为什么我可以从任何目录键入node -v?

[英]Once Node.js is installed on Win10 why can I type node -v from any directory?

Step 1) Install Node.js on Windows 10 system 步骤1)在Windows 10系统上安装Node.js

Step 2) Open cmd.exe 步骤2)打开cmd.exe

Step 3) c:\\Windows\\System32> shows up in console. 步骤3) c:\\Windows\\System32>显示在控制台中。

Step 4) type node -v and hit Enter 步骤4)输入node -v并按Enter

Result: v9.2.0 结果: v9.2.0

Question I don't understand the mechanics of this. 问题我不了解其机制。 Why does node -v work from any directory on my system? 为什么node -v从系统上的任何目录工作? Why don't I need to be in the node directory running an .exe file to check the version number? 为什么无需在运行.exe文件的节点目录中检查版本号? Once installed does node.js always run as some sort of background process? 安装后, node.js始终作为某种后台进程运行? Thanks so much for any insight! 非常感谢您的见解!

This is because the installation adds the directory in which your Node.js executable is found to your PATH environment variable. 这是因为安装会将在其中找到Node.js可执行文件的目录添加到PATH环境变量中。 You can learn more about the PATH variable here https://en.wikipedia.org/wiki/PATH_(variable) . 您可以在这里https://en.wikipedia.org/wiki/PATH_(variable)了解有关PATH变量的更多信息。

Drats, just a few seconds slow in answering. 小鸭,回答慢了几秒钟。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM