Vue3环境安装

terry-cc / 2024-01-14 / 原文

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash

source /home/cc/.bashrc

command -v nvm

nvm --version

# 安装指定的版本
nvm install v12.22.12

# 安装当前稳定的LTS版本
nvm install --lts

# 切换版本
nvm use v20.11.0

# 查看本地已安装的Node版本
nvm ls

# 查看所有可用版本
nvm ls-remote

# 查看当前镜像源
npm config get registry
https://registry.npmjs.org/

# 切换镜像源
npm config set registry https://registry.npm.taobao.org

# nrm是npm的镜像源管理工具,可以快速切换npm源
npm i -g nrm

nrm -V

nrm ls

nrm current

nrm use taobao

npm install --global yarn

yarn --version

npm create vue@latest
Need to install the following packages:
create-vue@3.9.1
Ok to proceed? (y) y

Vue.js - The Progressive JavaScript Framework

✔ Project name: … hello-vue3
✔ Add TypeScript? … No / Yes
✔ Add JSX Support? … No / Yes
✔ Add Vue Router for Single Page Application development? … No / Yes
✔ Add Pinia for state management? … No / Yes
✔ Add Vitest for Unit Testing? … No / Yes
✔ Add an End-to-End Testing Solution? › Cypress
✔ Add ESLint for code quality? … No / Yes
✔ Add Prettier for code formatting? … No / Yes

Scaffolding project in /mnt/d/Workspace/WebProjects/hello-vue3...

Done. Now run:

cd hello-vue3
npm install
npm run format
npm run dev

npm run dev
> hello-vue3@0.0.0 dev
> vite


VITE v5.0.11 ready in 8403 ms

➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
h

Shortcuts
press r + enter to restart the server
press u + enter to show server url
press o + enter to open in browser
press c + enter to clear console
press q + enter to quit
q

# 发布生产
npm run build

参考

WSL2下安装Node