For example, I want to put the above two folders in the main directory of NodeJS, so I will create two folders under NodeJs, "node_global" and "node_cache"
Now let's install a module to try and choose express, which is a more commonly used module. Also in the cmd command line, enter "npm install express -g" ("-g" means to install it in the global directory, which is the "C:\Program Files\nodejs\node_global" set above. )。 When the installation process in cmd is scrolling, it will prompt where "express" is installed, the version and its directory structure.
Go to the Environment Variables dialog box, create a new NODE_PATH under System Variables, and enter C:\Program Files\nodejs\node_global\node_modules. (PS: This step is quite critical.) )
Check whether the express installation is complete, open the cmd command line again, type: node, and when the ">" mark appears, type: require('exress') The purpose is to test whether the global path of the node is configured correctly. If correct, the cmd will list the relevant information. As follows:
Regarding the addition of environment variables: Since the default address of the module has been changed, the user variables above must be changed accordingly (user variables)PATH"C:\Program Files\nodejs\node_global\"), otherwise the input command will cause the error "xxx is not an internal or external command, nor is it a runnable program or batch file" when not using module.
|