# npm **Repository Path**: fly-sy/npm ## Basic Information - **Project Name**: npm - **Description**: 帮助所有人的包文件的发布,安装,依赖(如果你要下载a包,但是npm发现你的a包,需要依赖b包,所有会自动帮你下载b包) - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 5 - **Forks**: 1 - **Created**: 2022-07-15 - **Last Updated**: 2023-12-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 包的管理 就是管理包文件的:帮助所有人的包文件的发布,安装,依赖(如果你要下载a包,但是npm发现你的a包,需要依赖b包,所有会自动帮你下载b包) 常见的包管理:npm/cnpm/yarn ## node稳定版本v18.15.0 https://registry.npmmirror.com/binary.html?path=node/ ## npm + npm 是包的管理工具 + npm 是一个网站 https://npmjs.org ,主要管理一些第三方的包 ### 配置npm镜像 ```bash # 配置淘宝镜像 npm config set registry https://registry.npm.taobao.org # 查看镜像 npm config get registry # 安装nrm管理镜像(也可以不装) npm i nrm -g # 查看所有的镜像 nrm ls|list # 设置使用镜像 nrm use 镜像名称 ``` ### npm 常用命令 ```bash # 查看版本 npm -V # 初始化项目 npm init -y # 根据package.json安装依赖包 npm install 简写 npm i # 安装包 npm install 包的名称 -global(-g)|-save(-S)|-dev(-D) # 卸载包 npm uninstall 包的名称 -global(-g)|-save(-S)|-dev(-D) ``` ## cnpm ```bash # 安装cnpm npm install -g cnpm --registry=https://registry.npm.taobao.org # 查看cnpm版本 cnpm -v ``` ## yarn ```bash # 安装yarn npm i yarn -g # 查看yan版本 yarn --version # 安装包 yarn add 包的名称 -global(-g)|-save(-S)|-dev(-D) # 卸载包 yarn remove 包的名称 -global(-g)|-save(-S)|-dev(-D) # 根据package.json 安装依赖包 yarn ``` ## 解决 node-sass 网络慢的方法: ```bash npm config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g ```