table of Contents
-
- Node js installation
- Test whether the installation was successful
Node js installation
Download official website address: node.js
Download method:
[Note] If the computer system version is relatively high, you can choose to download the latest version, if the computer system version is low, you can choose the following method
Test whether the installation was successful
2-1. Open the command line window (cmd)
(1) Enter cmd in the search bar of the start menu
and press Enter directly (2) In any blank place of the computer, press the shift key + the right mouse button === "The menu appears === 》 Open the command line window here (W)
2-2 Enter the command to test in the command line window. Enter
node -v
and press Enter. If the detailed nodejs version number appears, it proves that the nodejs installation is successful.
If you enter the command and press Enter, the following prompt message appears: It proves that either the relevant command tool is not installed, or the installation
fails.'xxx' is not an internal or external command, nor is it an executable program or batch file.
After installation, create a folder locally to store the moudel module
step 1
Step 2
Step 3 Management commands for npm package
Install npm along with the installation of nodejs to
test whether npm can be used.
Enter npm -v and press Enter to use the
es6 module: Use a webapck packaging tool
Step 4 Enter nmp init -y in the command window and press Enter
Step 5 Enter nmp install (downloaded plug-in name) in the command window (eg: webpack webpack-cli)--save and press enter
The node_moduels file in the folder exists when it is in use and can be deleted when not in use. This file is relatively large and will take up a lot of space if copied. If you still need to use it after deleting it, you can enter npm i in the command line and press Enter. Recovery When
copying files: Do not copy node_modules (this is where third-party packages are stored and can be installed and deleted at any time)
Installation dependency:
execute the npm i command in the root directory of the project (the directory where the package.json file is located)
All the above preparations have been done, create a new folder in the directory folder
Open the zhaozhizu folder through vscode
Create an entry file in the src folder, which is a js file
Enter the code in index.js, enter the command npm run build in the command window and press Enter
Webpack related commands:
npm run build
npm run dev
There will be a main js file in this file. Enter the new execution code in the index file. By calling the npm run bulid command in the command window and pressing Enter, it will be output in the main js file
in the src folder, index The file belongs to the entry file, multiple files can be created in src, and these module files can be linked to each other