2018-09-16 admin


什么是npm,a package manager for JavaScript


npm(1) – a JavaScript package manager

Build Status


This is just enough info to get you up and running.

Much more info will be available via npm help once it’s installed.


You need node v6 or higher to run this program.

To install an old and unsupported version of npm that works on node v5 and prior, clone the git repo and dig through the old tags and branches.

npm is configured to use npm, Inc.'s public registry at by default. Use of the npm public registry is subject to terms of use available at

You can configure npm to use any compatible registry you like, and even run your own registry. Check out the doc on registries.

Super Easy Install

npm is bundled with node.

Windows Computers

Get the MSI. npm is in it.

Apple Macintosh Computers

Get the pkg. npm is in it.

Other Sorts of Unices

Run make install. npm will be installed with node.

If you want a more fancy pants install (a different version, customized paths, etc.) then read on.

Fancy Install (Unix)

There’s a pretty robust install script at You can download that and run it.

Here’s an example using curl:

curl -L | sh

Slightly Fancier

You can set any npm configuration params with that script:

npm_config_prefix=/some/path sh

Or, you can run it in uber-debuggery mode:

npm_debug=1 sh

Even Fancier

Get the code with git. Use make to build the docs and do other stuff. If you plan on hacking on npm, make link is your friend.

If you’ve got the npm source code, you can also semi-permanently set arbitrary config keys using the ./configure --key=val ..., and then run npm commands by doing node bin/npm-cli.js <command> <args>. (This is helpful for testing, or running stuff without actually installing npm itself.)

Windows Install or Upgrade

Many improvements for Windows users have been made in npm 3 - you will have a better experience if you run a recent version of npm. To upgrade, either use Microsoft’s upgrade tool, download a new version of Node, or follow the Windows upgrade instructions in the Installing/upgrading npm post.

If that’s not fancy enough for you, then you can fetch the code with git, and mess with it directly.

Installing on Cygwin



So sad to see you go.

sudo npm uninstall npm -g

Or, if that fails,

sudo make uninstall

More Severe Uninstalling

Usually, the above instructions are sufficient. That will remove npm, but leave behind anything you’ve installed.

If you would like to remove all the packages that you have installed, then you can use the npm ls command to find them, and then npm rm to remove them.

To remove cruft left behind by npm 0.x, you can use the included script file. You can run it conveniently like this:

npm explore npm -g -- sh scripts/

npm uses two configuration files, one for per-user configs, and another for global (every-user) configs. You can view them by doing:

npm config get userconfig   # defaults to ~/.npmrc
npm config get globalconfig # defaults to /usr/local/etc/npmrc

Uninstalling npm does not remove configuration files by default. You must remove them yourself manually if you want them gone. Note that this means that future npm installs will not remember the settings that you have chosen.

More Docs

Check out the docs.

You can use the npm help command to read any of them.

If you’re a developer, and you want to use npm to publish your program, you should read this.


When you find issues, please report them:

Be sure to include all of the output from the npm command that didn’t work as expected. The npm-debug.log file is also helpful to provide.

You can also find npm people in #npm on or on Twitter. Whoever responds will no doubt tell you to put the output in a gist or email.


  • npm(1)
  • npm-help(1)
  • npm-index(7)


转载请注明:文章转载自 JavaScript中文网 []



NPM酷库,每天两分钟,了解一个流行NPM库。· 在开发多国语言的项目时,为了给不同国家用户显示不同语言,我们一般会为每个语言分别建立一个Map映射,在界面上依据当前语言环境不同而输出不同语言库的字符串。 const MESSAGES =...
NPM酷库,每天两分钟,了解一个流行NPM库。· 上次,我们了解到如何使用numeral库格式化数字。今天我们继续认识另外一个用来格式化数字的库accounting。 accounting accounting 主要提供的方法有 forma...
NPM酷库,每天两分钟,了解一个流行NPM库。· 在NPM酷库044中,我们了解到了相对于JSON格式更加易于编写和维护的JSON5,今天我们继续学习另外一个更加简单易读的数据格式YAML。 下方就是一个YAML数据示例: --- rec...
纯前端控件集工具推荐:WijmoJS,支持 Npm 上安装和发布
专注企业应用开发的 WijmoJS ,是用 TypeScript 编写的新一代 JavaScript/HTML5 控件集。秉承触控优先的设计理念,WijmoJS 在全球率先支持 AngularJS,并提供性能卓越、零依赖的 FlexGrid...
前端每周清单第 47 期:NPM 年度报告与 2018 展望,Airbnb React Router 实践
前端每周清单专注前端领域内容,以对外文资料的搜集为主,帮助开发者了解一周前端热点;分为新闻热点、开发教程、工程实践、深度阅读、开源项目、巅峰人生等栏目。欢迎关注【前端之巅】微信公众号(ID: frontshow),及时获取前端每周清单。 ...
【工具官网】 Node.js : 淘宝NPM: 【安装步骤】 一、安装node.js 1.前往node.js官网下载并安装工具,这里安装路径选到D盘,D:P...
概述 Node.js用c++语言编写而成的,是一个基于chrome V8引擎的javascript运行环境,让javaScript的运行脱离浏览器服务端,可以使用javaScript语言书写服务器端代码 1.使用node来实现一个http服...
NPM酷库,每天两分钟,了解一个流行NPM库。· 今天我们来了解一个专门用来处理IP地址的库:ip,ip库能够获取本机IP地址、比较、转换、掩码/子网计算等各种和网络IP相关的操作: const ip = require(&#x27;ip...
使用npm-scripts发布Github Pages
将项目打包后部署到GitHub Pages 上是常见需求。 这里总结下通过npm-srcrips将项目发布到gh-pages分支。需要使用到gh-pages的库。 需要用到的环境 node npm 或者yarn 本地项目,需要通过crea...
原文:Understanding differences between npm, yarn and pnpm 作者:Alex Kras 翻译:雁惊寒 本文作者对比了当前主流的包管理工具npm、yarn、pnpm之间的区别,并提出了合...