NodeJS's initial experience difficulties and nodeJS's initial experience
Because the new company needs to use nodeJS, I just learned it. Let's take a look at nodejs Baidu encyclopedia first. We know that it is a js environment executed on the server side. The following are pitfalls:
The first pitfall is that after nodejs is installed, the environment variable of path will be automatically configured. I checked the path and found that the path is automatically added. Therefore, I run the command directly in the Command window and the result is "not an internal or external command ". I thought that because nodejs is installed in the C: \ Program Files directory by default and the folder has spaces, I uninstalled nodejs and installed it on disk D, it is found that the path has been configured in the new installation directory, but "not an internal or external command" still appears ".
Path:
Finally, restart the computer and solve the problem. (Above I used cd to the installation directory)
The second pitfall is that after I jump to the installation directory through cd, the file is executed directly, and the file to be executed is on the desktop, so the problem occurs.
There are two ways to solve this problem: first, the directory jumps to the directory of the executed file through cd. 2. Copy the executed file to the installation directory.
Hello. js has only one sentence: console. log ("Hello World ");
========================================================== ======
To sum up:
1. First install nodejs on the official website. Everything is installed by default.
2. Create a New hello. js file at any location. The file content is console. log ("Hello World ");
3. Restart your computer (important)
4. Go to the "hello. js" directory on the command line and execute "node hello. js.