Installation and use of scaffolding
Take vue-CLI as an example:
We use the NPM command to install the scaffolding: NPM install -g@vue /cli
Enter the command to quickly build the project using scaffolding: vue create my-vue-app
A simple breakdown of the commands we enter on the command line, vue is understood as the scaffold’s main command, create is the scaffold’s command, and my-vue-app is the command parameter param.
What the system does after the scaffolding command is executed
1. Look for the main command vue in the system environment variable
2. Locate the vue command and run the vue file. For clarification, the vUE file is of type LRWXR
-xr-x is a link file, similar to a shortcut in Windows. It actually executes the node/lib/node_modules/@vue/cli/bin/vue.js file
3. Run the vue.js file to parse the command and command param entered in the command line
4. The command execution
5. No further action is required.
How scaffolding works. – Answer the question
Why did we create the vue command after installing @vue/clil?
There is a package.json file in the vue-CLI installation directory that contains a bin configuration. The key: vue of the bin object indicates the name of the command created in the system environment variable after the installation. The value: bin/vue.js of the bin object indicates the file actually executed after the vue command is executed.
What happens when you install @vue/ CLI globally?
1. Install @vue/ CLI in node lib/node_modules
2. After the installation is complete, the system parses the package.json file and checks whether the bin property is configured in the file
3. If package.json contains the bin property, a global directive will be created in the node bin directory with the key declared in bin and linked to the value declared in bin, that is, a link file vue will be generated to point to bin/vue.js. You can also think of the linked file vue as a shortcut to bin/vue.js.
What happens when the vue command is executed? Why does vue point to a JS file when we can execute it using vue commands?
1. Vue command system will be found in the environment variable when the command is the corresponding file and execute it, vue command on the command line and implementation link files vue/Users/tyro/NVM/versions/node/v14.5.0 / bin/vue are equivalent.
2. Although the vue command points to vue.js, we usually execute js files through Node vue.js. If node is omitted, why is vue.js executed as well? The answer is that the first line in vue.js does: #! The/usr/bin/env node. Executing this line of code causes the system to find node in the environment variable and execute it, which is equivalent to executing Node vue.js.