1、NPM 简介

1.1 NPM

  • Node.js® 是一个基于 Chrome V8 引擎的 JavaScript 运行环境,可方便地构建快速,可扩展的网络应用程序的平台。Node.js 使用事件驱动,非阻塞式 I/O 模型,使其轻量又高效,可运行在不同的设备上。

    • 从 Node.js 官方网站的企业登记页,包括我们熟知的公司有 LinkedIn, Yahoo, Paypal, eBay, Walmart,Groupon 还有很多的中小型公司,国内的公司如雪球、淘宝、网易、百度等也都有很多项目运行在 Node.js 之上。

    • Node.js 官网

    • Node.js 中文网

  • 它的包生态系统 NPM,是目前世界上最大的开源库生态系统。

    • NPM(node package manager),通常称为 node 包管理器。使用 NPM 可以对 node 包进行安装、卸载、更新、查看、搜索、发布等操作。安装完 Node.js,NPM 就可以直接用了。

2、NPM 环境配置

2.1 安装 Node.js

2.2 安装 NPM

  • 安装完 Node.js,NPM 就可以直接用了。

2.3 NPM 常用命令

  • 1)NPM 常用命令

    # 查看 NPM 版本
    $ npm -v # 更新 NPM 版本
    $ sudo npm i -g npm # 在官方包仓库中搜索包
    $ npm search [包名]
    $ npm search express # 查看官方包仓库中包所用 package.json 文件中的信息
    $ npm view [包名]
    $ npm view express # 安装 package.json 文件中列出的包
    $ npm install # 安装包 # 安装在本地项目中
    $ npm install [包名]
    $ npm install express # 安装在全局中
    $ npm install -g [包名]
    $ npm install -g express # 安装并保存包到 package.json 文件中 # 安装在本地项目中
    $ npm install [包名] --save
    $ npm install express --save # 安装在全局中
    $ npm install -g [包名] --save
    $ npm install -g express --save # 查看安装的包 # 本地
    $ npm list # 全局
    $ npm list -g # 查看过期的包 # 本地
    $ npm outdated # 全局
    $ npm outdated -g # 更新全部包 # 本地
    $ npm update # 全局
    $ npm update -g # 更新指定的包 # 本地
    $ npm update [包名]
    $ npm update express # 全局
    $ npm update -g [包名]
    $ npm update -g express # 卸载包 # 本地
    $ npm uninstall [包名]
    $ npm uninstall express # 全局
    $ npm uninstall -g [包名]
    $ npm uninstall -g express # 查看全局包的安装路径
    $ npm root -g # 修改全局包的安装路径,修改后为 [安装路径]\node_modules\
    $ npm config set prefix "[安装路径]"
    Usage: npm <command>
    
    where <command> is one of:
    access, adduser, bin, bugs, c, cache, completion, config,
    ddp, dedupe, deprecate, dist-tag, docs, doctor, edit,
    explore, get, help, help-search, i, init, install,
    install-test, it, link, list, ln, login, logout, ls,
    outdated, owner, pack, ping, prefix, profile, prune,
    publish, rb, rebuild, repo, restart, root, run, run-script,
    s, se, search, set, shrinkwrap, star, stars, start, stop, t,
    team, test, token, tst, un, uninstall, unpublish, unstar,
    up, update, v, version, view, whoami npm <command> -h quick help on <command>
    npm -l display full usage info
    npm help <term> search for help on <term>
    npm help npm involved overview Specify configs in the ini-formatted file:
    /Users/qianchia/.npmrc
    or on the command line via: npm <command> --key value
    Config info can be viewed via: npm help config

2.4 注意事项

  • 一般 Node modules 通常被安装在每个项目的本地文件夹 node_modules 中,但下面几个包推荐安装在全局:

    • CoffeeScriptLessGruntGulp
    # 安装 coffee-script
    $ npm install -g coffee-script # 安装 less
    $ npm install -g less # 安装 grunt-cli
    $ npm install -g grunt-cli # 安装 gulp
    $ npm install -g gulp

最新文章

  1. java之文件基本操作
  2. 关于DMA和它的仇家
  3. apk签名(不打包)
  4. php课程---文件操作及文件上传的代码总结
  5. AndroidManifest.xml
  6. Vim杂记:Sublime的配色方案
  7. Uva(10048),最短路Floyd
  8. tensorflow + pycharm安装即相关资料
  9. 【转】十二个移动App云测试服务盘点
  10. PHP和MYSQL的编码问题
  11. 被墙的情况(同时下载AndroidSDK达到200+kb/s)
  12. asp.net学习之ado.net(连接模式访问)
  13. Android ListView 中的checkbox
  14. C#发送带附件的邮件的代码
  15. linux视频录制,推流处理
  16. AES加密解密 助手类 CBC加密模式
  17. return返回两个三元表达式的和,返回不正确,同样要注意在JavaScript中,也是如此
  18. messageBox 的几种显示方式
  19. C#编程(六十五)----------表达式树
  20. 多作者wordpress博客彻底屏蔽可视化编辑

热门文章

  1. RefreshListView中onItemClick点击错位
  2. 构建高性能服务(二)java高并发锁的3种实现
  3. Windows 服务安装教程
  4. 高效率、简洁、CSS代码优化原则
  5. JAVA GC优化入门
  6. 【leetcode】solution in java——Easy5
  7. linux下切换python2和python3(转)
  8. 转:CentOS系统yum源配置修改、yum安装软件包源码包出错解决办法!
  9. Windows Live Writer离线写CSDN博客
  10. 下拉列表框select