一、常用命令
1、npm命令
1、npm -v 查看 npm 的版本
2、安装包方法 npm install XXX(包名)
3、卸载安装的包 npm uninstall jquery 或 npm remove jquery
npm uninstall xxxxx -g //表示卸载全局依赖包
4、npm info jquery 查看包的详细信息
5、查看一个包存在的所有版本号 npm view jquery versions
6、查看指定包当前的最新版本 npm view jquery version
7、下载指定版本的包 npm install jquery@3.4.1
8、npm list 查看项目安装了哪些包
加上 --depth 0 可以限制结果的层数,输出结果也不会太长
加上 -g 可以输出全局模块,也可以和–depth 0并用
npm ls -g --depth 0
9、npm install jquery --save 或 npm i jquery -S 注:--save 表示 在 package.json 文件中(dependencies)记录 下载包的版本信息;
10、npm install jquery --save-dev 或 npm i jquery -D 下载开发依赖包,上一条命令是下载生产依赖包(这里就不讲开发依赖和生产依赖的区别);
11、npm root -g 查看全局安装包的存放位置
12、npm audit fix 包的修复 ,一般是包的更新
13、npm ls jquery 查看当前安装包的版本
14、npm config set registry https://registry.npm.taobao.org 更改 npm 的下载镜像为淘宝镜像
2、git命令
3、Redis清除缓存
flushdb或者flushAll命令,执行即可
4、查找哪个程序占用 80 端口
1)“运行”中输入 cmd
2)在命令行中输入 netstat-ano (中间有空格),得到端口号对应的PID
5、打开vue图形化界面
vue ui
二、遇到的问题
1、运行npm install 时报错zlib: unexpected end of file
解决方法
运行npm cache clean --force 清空npm缓存即可决这个问题
2、npm运行报错TypeError: loaderContext.getResolve is not a function
导致错误原因可能为:
1、安装 npm install less less-loader --save
2、配置,在webpack.base.conf.js 的 rules 节点下新增:
{
test: /\.less$/,
loader: "style-loader!css-loader!less-loader"
}
3、使用,在 style 标签中使用 lang="less"
4、编译运行,此时可能会报错:
Module build failed: TypeError: loaderContext.getResolve is not a function
这个错误一般都是由less-loader版本过高导致的,版本号可以在 package.json 中查看;
卸载原来的 npm uninstall less-loader;
安装指定版本 npm install less-loader@4.1.0 --save