2

I use windows10.
My node.js's path is C:\Program Files\nodejs\node.exe and I can use node command.

But I haven't set my environment variable path.
It does not mean just that I have not set it myself. I checked the user environment variables and the system environment variables but could not find them. (The path of npm was in the user environment variable.)

Why can I use node command without setting path?

2
  • 1
    Did you install Node.js via the installer from the website? It set's the paths for you. Commented Jun 16, 2019 at 3:33
  • Yes. But when I check my environment variable paths, I can't find path of node.exe. (C:\Program Files\nodejs\node.exe) Commented Jun 16, 2019 at 9:24

1 Answer 1

6

For the node command to work in Windows from a command shell, one of the following must be true:

  1. Your current directory in the command shell is C:\Program Files\nodejs and thus node.exe or node.bat can be found in that current directory.

  2. C:\Program Files\nodejs is in the search path which can be either a system wide path setting or a local user path setting (what you see in the environment is a combination of those two).

  3. There is a node.bat file somewhere in your system path or in the current directory that launches node.exe for you by directly referencing its path.

On Windows, you can type "where node" in the command shell and it will tell you where it's finding the file to run. If what it is finding is not in the current directory, then you must have its directory in your path somewhere.

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you. I run where node and get C:\Program Files\nodejs\node.exe. I can't find neither node.bat nor node.exe in current directory. (current dir is C:\users\user). And I also can't find environment variable path to C:\Program Files\nodejs.
@invalid - Open up a command shell. Type path. Study the result. I bet you find C:\Program Files\nodejs in it.
Yes!! I found it. Thank you!! But why doesn't it appear in environment variable setting?
@invalid - There are two places environment settings are configured. One is per user and one is per computer. Depending upon how nodejs is installed (for all users or for just one user), it would put it in one or the other of the two environment settings.
@invalid - Got to Settings in Windows. In the search bar in the upper left, type "environment" (without the quotes). First pick "Edit the System Environment Variables". In the resulting dialog, select the button "Environment Variables...". You will find "Path" listed in both "User Variables" and in "System Variables". Select "Path" in the "System Variables" and click the relevant "Edit..." button. Look for the c:\program files\nodejs listing. That's where I see it on my system. If you don't see it there, then repeat the process in the "User Varables" section of the same dialog.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.