Install Vue environment and build/generate
1. Download and install Node.js
Visit https://nodejs.org/zh-cn/ and download the latest LTS version of Node.js. The installation steps are simple, just keep clicking next.
2. Compile the project
Open cmd in the project directory, as shown in the folder below.
Enter npm install to install the required dependencies
npm install
Enter npm run dev to run the project
npm run dev
3. Possible problems
1. Unable to access remote repository
You can use the domestic Taobao mirror, enter the following commands:
npm config set registry https://registry.npm.taobao.org
npm config get registry // Verify if the setting is successful
2. Insufficient permissions to perform certain operations
Open cmd as administrator
3. Unable to compile normally, missing certain components
npm install –global –production windows-build-tools
4. Missing a specific dependency (using node-sass as example)
npm install node-sass
*************************************
npm run dev
npm run serve
Install development dependencies:
npm install babel-plugin-import -D
*********************************************
Build
npm run build
*********************************************
Vue executes npm run dev and reports an error: missing script:dev
Check the package.json file in the project folder, there may be two situations:
1. There is a dev line in the script
2. There is no dev line in the script
[Insert image description]
Has dev
Developers who have the dev line in the script need to check the folder when opening the terminal.
If there is no dev in the script, you need to re-download it, then run npm install to install dependencies, and finally npm run dev. If there is no dev but serve, you can try running the vue project with npm run serve command.
npm install webpack -g
npm-windows-upgrade and select version 8.12.1 for installation. (Then select version 8.12.1 to download.)
Solve npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead.
Just upgrade npm to the latest version
Upgrade method:
1. Open cmd as administrator in Windows, then execute the command
npm install -g npm-windows-upgrade
2. Change script policy
Download Windows Power Shell
Then run as administrator, execute the command
set-ExecutionPolicy RemoteSigned
Solve npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead. (Figure 1)
Enter Y
Successfully changed script policy
3. Run the command on Windows Power Shell
npm-windows-upgrade
Problem solved!
Solve: vue : The term ‘vue’ is not recognized as the cmdlet
Error reason:
Vue-cli is not installed
Solution: Install vue-cli
npm install vue-cli -g
npm audit
-
Alipay QR Code Scan
-
WeChat Scan Pay