npm

2018-09-16 admin

npm是什么

什么是npm,a package manager for JavaScript

npm使用教程帮助文档

npm(1) – a JavaScript package manager

Build Status

SYNOPSIS

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

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

IMPORTANT

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 https://registry.npmjs.org by default. Use of the npm public registry is subject to terms of use available at https://www.npmjs.com/policies/terms.

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 https://www.npmjs.com/install.sh. You can download that and run it.

Here’s an example using curl:

curl -L https://www.npmjs.com/install.sh | sh

Slightly Fancier

You can set any npm configuration params with that script:

npm_config_prefix=/some/path sh install.sh

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

npm_debug=1 sh install.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

No.

Uninstalling

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 clean-old.sh script file. You can run it conveniently like this:

npm explore npm -g -- sh scripts/clean-old.sh

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.

BUGS

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 https://package.community/ or on Twitter. Whoever responds will no doubt tell you to put the output in a gist or email.

SEE ALSO

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

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-40429.html

文章标题:npm

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