NodeJS 常用代码
安装前/后相关命令
命令 | 说明 |
---|---|
node -v | 检查当前 node 的版本 |
npm -v | 检查当前 npm 版本 |
安装相关命令
命令 | 说明 |
---|---|
npm root -g | 查看 npm 全局安装路径 |
npm bin -g | 查看 npm 的可执行文件所在目录 |
npm install <包名> | 安装指定的包 |
npm search <包名> | 搜索指定的包名 |
npm install <包名>@版本号 | 安装指定版本的包 |
npm list <包名> | 查看包的版本信息 |
npm ls | 查看安装的包列表 |
npm update <包名> | 更新指定包 |
npm uninstall <包名> | 卸载指定包 |
npm install <包> -g | 全局安装 |
install <包名> --save | 在当前目录安装包 |
npm config list | 查看配置列表 |
仓库相关命令
命令 | 说明 |
---|---|
npm adduser --registry <仓库地址> | 创建仓库用户 |
npm config get registry | 查看 npm 当前镜像源 |
npm config set registry <镜像地址> | 设置 npm 镜像源 |
npm publish <包名> | 发布一个包到仓库中 |
运行模块相关命令
命令 | 说明 |
---|---|
npm start [-- args] | 启动对应模块 |
npm stop [-- args] | 停止对应模块 |
npm restart [-- args] | 重启对应模块 |