js-package managers

Node.js Package Manager

npm
Yarn
pnpm

npm was the first package manager to introduce the concepts of registry protocol and packaging standards. It was released back in 2010 and officially adopted by the Node.js team shortly afterward, which was the turning point for npm.

Yarn 改进了 npm 的问题

使用 yarn,管理员权限运行控制台输入下面命令

// 安装 corepack
corepack enable
// 初始化项目
yarn init -2

Accessing the list of commands

// Accessing the list of commands
yarn help

//Starting a new project
yarn init

//Installing all the dependencies
yarn
yarn install

//Adding a dependency
yarn add [package]
yarn add [package]@[version]
yarn add [package]@[tag]

// Adding a dependency to different categories of dependencies
yarn add [package] --dev # dev dependencies
yarn add [package] --peer # peer dependencies

// Upgrading a dependency
yarn up [package]
yarn up [package]@[version]
yarn up [package]@[tag]

// Removing a dependency
yarn remove [package]

// Upgrading Yarn itself
yarn set version stable
yarn set version latest
yarn set version from sources

创建项目

yarn create vite my-vue-app --template vue

停用 Vetur 插件,不然会影响 vue3 语法的识别,如果有安装Vue VSCode Snippets 插件也要停用,不然该插件会强制启动Vetur插件
vscode 安装 Vue Language Features 和 TypeScript Vue Plugin这两个插件用于识别vue3里的最新语法及vue3里的ts语法