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酷库:accounting,格式化数字和货币
NPM酷库,每天两分钟,了解一个流行NPM库。· 上次,我们了解到如何使用numeral库格式化数字。今天我们继续认识另外一个用来格式化数字的库accounting。 accounting accounting 主要提供的方法有 forma...
2018-02-08
将 Vue 组件库发布到 npm
制作了一套自己的组件库,并发布到npm上,项目代码见 GitHub 。 前期准备 搭建项目 vue init webpack hg-vcomponents cd hg-vcomponents cnpm install 目录结构 - vue-...
2018-02-17
解决npm ERR! Unexpected end of JSON input while parsing near的方法汇总
这两天执行 npm install 时会报错误: npm ERR! Unexpected end of JSON input while parsing near 这个错误的解决方法有以下几种: 1.删掉package.lock.json...
2018-07-16
NPM酷库:pify 将异步函数Promise化
NPM酷库,每天两分钟,了解一个流行NPM库。 所有Node.js标准库和很多第三方库提供的接口都是callback样式的,在ES7标准时代,使用async/await配合Promise才是最佳实践。 昨天我们了解到可以用bluebird库...
2018-01-31
NPM酷库:intl-messageformat,多语言处理
NPM酷库,每天两分钟,了解一个流行NPM库。· 在开发多国语言的项目时,为了给不同国家用户显示不同语言,我们一般会为每个语言分别建立一个Map映射,在界面上依据当前语言环境不同而输出不同语言库的字符串。 const MESSAGES =...
2018-02-08
NPM酷库:ip,IP地址处理
NPM酷库,每天两分钟,了解一个流行NPM库。· 今天我们来了解一个专门用来处理IP地址的库:ip,ip库能够获取本机IP地址、比较、转换、掩码/子网计算等各种和网络IP相关的操作: const ip = require(&#x27;ip...
2018-02-08
npm及cnpm(Windows)基础环境搭建
【工具官网】 Node.js : http://nodejs.cn/ 淘宝NPM: https://npm.taobao.org/ 【安装步骤】 一、安装node.js 1.前往node.js官网下载并安装工具,这里安装路径选到D盘,D:P...
2018-05-13
Npm vs Yarn 之备忘大全
有则笑话,如此讲到:“老丈人爱吃核桃,昨天买了二斤陪妻子送去,老丈人年轻时练过武,用手一拍核桃就碎了,笑着对我说:你还用锤子,你看我用手就成。我嘴一抽,来了句:人和动物最大的区别就是人会使用工具。……”。撇开这样特例场景,这句话还是非常用...
2018-02-03
纯前端控件集工具推荐:WijmoJS,支持 Npm 上安装和发布
专注企业应用开发的 WijmoJS ,是用 TypeScript 编写的新一代 JavaScript/HTML5 控件集。秉承触控优先的设计理念,WijmoJS 在全球率先支持 AngularJS,并提供性能卓越、零依赖的 FlexGrid...
2018-04-23
详解node.js中的npm和webpack配置方法
概述 Node.js用c++语言编写而成的,是一个基于chrome V8引擎的javascript运行环境,让javaScript的运行脱离浏览器服务端,可以使用javaScript语言书写服务器端代码 1.使用node来实现一个http服...
2018-01-26
回到顶部