IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    npm 备忘录

    雨浣潇湘发表于 2019-05-15 07:45:00
    love 0

    常用命令

    1
    $ npm init / install / uninstall / update
    1
    2
    $ npm ls
    $ npm list -g --depth 0
    1
    2
    npm config set proxy xxx.com
    npm config list
    1
    2
    3
    4
    $ npm outdated
    Package Current Wanted Latest Location
    @commitlint/cli 7.1.1 7.5.2 7.5.2 test
    @commitlint/config-angular 7.1.1 7.5.0 7.5.0 test
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    $ npm view @test/test-util

    @test/test-util@0.3.101 | ISC | deps: none | versions: 242

    dist
    .tarball http://rnpm.hz.netease.com/@test/test-util/download/@test/test-util-0.3.101.tgz
    .shasum: a10f3595eb4cbbdd0d1d49691acf2116bfa832bf

    maintainers:
    - aaa <aaa@163.com>
    - bbb <bbb@163.com>
    - ccc <ccc@163.com>

    dist-tags:
    dev: 0.3.101-0 latest: 0.3.101 test: 0.0.66

    published 2 days ago by ddd <ddd@163.com>
    1
    2
    3
    4
    5
    $ cd path/project
    $ npm install path/package

    $ cd path/project
    $ npm link path/package
    1
    2
    3
    4
    $ npm adduser
    Username:
    Password:
    Email: (this IS public)
    1
    2
    $ npm publish
    $ npm publish --tag=test
    1
    $ npm access # 设置权限
    1
    2
    $ npm help install
    # 打开 file:///C:/Users/Forever/AppData/Roaming/npm/node_modules/npm/html/doc/cli/npm-install.html

    私有 NPM

    私有包托管在内部服务器或者单独的服务器上;
    可以同步整个官方仓库,也可以只同步需要的;
    对于下载,发布,有对应的权限管理。

    官方

    缺点:贵
    优点:开源闭源项目统一托管

    sinopia

    https://github.com/rlidwka/sinopia
    很久不维护了;
    权限管理比较弱;
    缓存优化不足;
    不能做官方仓库的镜像。

    verdaccio

    https://github.com/verdaccio/verdaccio
    优点:免费;本地速度快,带公有库缓存;支持 yarn
    缺点:需要自己托管维护

    cnpm

    https://github.com/cnpm/cnpmjs.org

    配置:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    // ~/.cnpmjs.org/config.json
    {
    "mysqlServers": [
    {
    "host": "host",
    "port": 3306,
    "user": "lakers",
    "password": "password"
    }
    ],
    "mysqlDatabase": "cnpmjs", // 数据库名
    "enablePrivate": true, // 是否启用私有化,这样只有定义在 `admins` 中的用户才能发布
    "admins": {
    // 管理员配置,可以配置多个
    "senntyou": "LakersChampionship@163.com"
    },
    "syncModel": "exist", // 同步模式
    "scopes": [
    // 包前缀,如果不是以这个前缀命名的包将不能发布,可以配置多个
    "@lakers"
    ],
    "registryHost": "http://lakers.company.npm.registry.com", // 你的服务器对应的 npm registry 地址
    "officialNpmRegistry": "https://registry.npm.taobao.org"
    }
    1
    2
    3
    $ cnpmjs.org start

    $ cnpm config set registry http://your.company.npm.registry.com


沪ICP备19023445号-2号
友情链接