npm 上传包

  |  
 阅读次数

npm上传包,github封装库

  1. github新建项目,上传项目,根据杨清项目配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    {
    "name": "absweek",
    "version": "1.0.2",
    "description": "获取从1970.1.1 至今 绝对星期数",
    "private": false,
    "author": "LiSC <903317164@qq.com>",
    "license": "MIT",
    "repository": {
    "type": "git",
    "url": "https://github.com/SunOfHomeBoy/absWeek"
    },
    "main": "./index.js",
    "typings": "./index.d.ts",
    "scripts": {
    "build": "tsc --declaration true --noImplicitUseStrict --removeComments ./index.ts"
    },
    "dependencies": {}
    }
  2. 配置好项目 npm login

  3. npm publish . 上传项目
    NOTE: 版本号,项目名称禁止大写,Token,添加github地址,上传包之前编译。TS版,包声明。

  4. 在其他项目 npm install ‘包名’

  5. 引入,调用