felenwe 2015-12-28 7283浏览量
npm(node package manager),是node.js的一个包管理器,用于第三方模块的下载、安装和管理。
npm收录着庞大而丰富的第三方资源,截至目前为止已经收录了220102个包。npm之于node.js,其重要程度可比maven与java、pip与python。
一、npm安装
npm的安装非常简单,在linux下只要一条命令即可完成安装,如下:apt-get install npm
安装完后,运行“npm”命令检查一下是否安装成功,出现如下提示说明安装成功:lee@mypc ~ $ npm Usage: npm <command> where <command> is one of: access, add-user, adduser, apihelp, author, bin, bugs, c, cache, completion, config, ddp, dedupe, deprecate, dist-tag, dist-tags, docs, edit, explore, faq, find, find-dupes, get, help, help-search, home, i, info, init, install, issues, la, link, list, ll, ln, login, logout, ls, outdated, owner, pack, ping, prefix, prune, publish, r, rb, rebuild, remove, repo, restart, rm, root, run-script, s, se, search, set, show, shrinkwrap, star, stars, start, stop, t, tag, team, test, tst, un, uninstall, unlink, unpublish, unstar, up, update, upgrade, v, verison, version, view, whoami npm <cmd> -h quick help on <cmd> npm -l display full usage info npm faq commonly asked questions npm help <term> search for help on <term> npm help npm involved overview Specify configs in the ini-formatted file: /home/lee/.npmrc or on the command line via: npm <command> --key value Config info can be viewed via: npm help config npm@3.3.12 /usr/local/lib/node_modules/npm
二、npm使用说明
1、模式
npm有全局和本地两种模式。
本地模式是npm的默认模式,这种模式的工作范围仅限于当前的工作目录下,任何操作都不会影响电脑上的其他node.js代码。
eg. 把log4js安装到当前项目下
npm install -d log4js
eg. 安装express
npm install -g express
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
集结各类场景实战经验,助你开发运维畅行无忧