Detailed explanation of win10 system computer cmd command box prompts "webpack is not an internal command"

Without further ado, let's go straight to the tutorial.

1. Install nodejs---pay attention to the installation path (ps: the name is not important, the important thing is the path. Whether you install it by default or manually select the path to install, please remember the path)

nodeJS Chinese website download address: (Note that the system is 32-bit or 64-bit, please check the computer system first)

http://nodejs.cn/download

Now installing nodeJS will automatically install npm package management.

After the installation is complete, enter the following command to check whether the installation is correct.

See my nodejs installation path name here, the folder name is not important.

At this point, nodeJS is installed successfully.

2. Then create two folders node_cache and node_global under the noodjs\noodjs folder.

As shown below.

3. This step is very important. Open the command line controller (cmd). Enter the following two lines of command code.

After each input line and press Enter, cmd has no response, which is a normal phenomenon.

npm config set cache  "E:\nood js\nood_js\node_cache"

npm config set prefix "E:\nood js\nood_js\node_global"

4. Install webpack globally.

npm install webpack -g

ps: Install the specified version of webpack, as follows

npm install [email protected] -g

@ is followed by the version number

After the installation is successful, you can see that there is a new file webpack in the previously created folder

5. Top priority. system environment variables

Open Computer Properties. Right-click the computer icon and click "Properties"

Configure environment variables interface. The final interface is as follows.

Start establishing system environment variables. Click the New button for User Variables and System Variables. Create the environment variables as shown below.

Pay attention to the path: In some online tutorials, the node_modules of E:\nood js\nood_js\node_global\ node_modules are brought into the environment variable, so that webpack cannot be used.

Variable name: NODE_PATH

Variable value: E:\nood js\nood_js\node_global

After the first step is completed, the next step is how to configure the environment variables into the system. Please see picture.

Double-click "Path" for user variables and system variables, respectively. Pop up as follows. Click New (N).

Then wrap the previously configured NODE_PATH with %. as follows:

                            %NODE_PATH%

Note: Don't miss anything. Both user variables and system variables operate as follows. The following figure is the Path of the user variable.

The Path value of the system variable is a little more, as shown below.

4. Open cmd, enter node and press Enter, then enter   require('webpack')

{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324058845&siteId=291194637