npm

作者: 你喜欢吃青椒吗_c744 | 来源:发表于2019-08-22 21:59 被阅读0次

学习于廖雪峰的官方网站

npm其实是Node.js的包管理工具(package manager)。

为啥我们需要一个包管理工具呢?因为我们在Node.js上开发时,会用到很多别人写的JavaScript代码。如果我们要使用别人写的某个包,每次都根据名称搜索一下官方网站,下载代码,解压,再使用,非常繁琐。于是一个集中管理的工具应运而生:大家都把自己开发的模块打包后放到npm官网上,如果要使用,直接通过npm安装就可以直接用,不用管代码存在哪,应该从哪下载。

更重要的是,如果我们要使用模块A,而模块A又依赖于模块B,模块B又依赖于模块X和模块Y,npm可以根据依赖关系,把所有依赖的包都下载下来并管理起来。否则,靠我们自己手动管理,肯定既麻烦又容易出错。

讲了这么多,npm究竟在哪?

其实npm已经在Node.js安装的时候顺带装好了。我们在命令提示符或者终端输入npm -v,应该看到类似的输出:

C:\>npm -v
4.1.2

如果直接输入npm,你会看到类似下面的输出:

Usage: npm <command>

where <command> is one of:
    access, adduser, audit, bin, bugs, c, cache, ci, cit,
    clean-install, clean-install-test, completion, config,
    create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
    edit, explore, get, help, help-search, hook, i, init,
    install, install-ci-test, install-test, it, link, list, ln,
    login, logout, ls, org, 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:
    C:\Users\Administrator\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@6.9.0 C:\Program Files\nodejs\node_modules\npm

上面的一大堆文字告诉你,npm需要跟上命令。现在我们不用关心这些命令,后面会一一讲到。目前,你只需要确保npm正确安装了,能运行就行。

相关文章

  • Vue-cli环境安装

    1:升级npm #查看npm的版本$ npm -v #使用npm升级npm的版本$ npm npm install...

  • NPM指令

    NPM指令 升级npm npm install npm -g 安装模块 npm install

  • Node 的生态NPM

    npm i 【npm install】 安装 npm install npm -g npm的三个部分 npm 官网...

  • npm

    一、npm 发包相关指令 npm adduser npm publish npm update npm versi...

  • node、npm 常见操作

    node、npm 查看版本 $ node -v$ npm -v npm 升级 $ npm i -g npm@latest

  • NPM 常用命令

    这里介绍的命令有如下: npm -v npm init npm install npm list npm unin...

  • npm 常用命令

    查看所有配置 npm config list 查看npm版本 npm -v 升级npm版本 npm install...

  • npm 常用命令

    npm init npm install jquery npm i jquery npm uninstall jq...

  • vue-cli中使用vue-router实例

    一、安装(npm)1、安装相关包 npm install npm //更新npm到最新版 npm in...

  • npm安装的node如何升级?

    1.升级npm npm install -g npm 2.清除npm缓存 npm cache clean -f 3...

网友评论

      本文标题:npm

      本文链接:https://www.haomeiwen.com/subject/gmxasctx.html