认识npm

时间:2021-02-01 12:59:49   收藏:0   阅读:0

1.1 npm介绍

npm(Node Package Manager)node的包管理器,其实它面向的是整个JavaScript的。npm随同NodeJs一起安装。npm -v检查安装版本

1.2 npm 常用命令

使用 npm 初始化管理项目,创建package.json文件。参数-y 自动应答。

npm init -y

使用 npm 命令安装模块。

-S / --save 生产环境--项目上线之后依然会使用
-D / --save-dev 开发环境--只在开发阶段会使用
-g 全局安装

install可以简写为i。

npm install <参数>

卸载模块(uninstall可以简写为un)

npm uninstall <参数>

更新模块(@版本号 指定版本 )

npm update

查看当前安装的模块

npm list

查看所有全局安装的模块:

npm list --depth=0 -global

登录npm:

npm login

上传包到服务器:

npm publish

从npm服务器删除当前包:

npm unpublish

1.3 使用淘宝镜像

npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install [name]

1.4 npm的使用

在NodeJs中通过npm下载某个包之后,可以通过引入模块的形式来使用。

const express = require("express");
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!