丁同亚的博客
夺朱非正色

发布自己的npm包

打个广告 我写的例子 npm包 codefilecount 统计文件个数和代码行数

  1. npm init 初始化项目
  2. 修改 package.json
    {
        "name": "codefilecount",
        "version": "1.0.2",
        "description": "统计代码文件个数和代码行数",
        "main": "index.js",
        "bin": {
            "codestats": "./src/index.js"//配置命令行命令 codestats, 全局安装后命令行执行命令 codestats 则会执行./src/index.js文件
        },
        "scripts": {
            "test": "codefilecount",
            "start": "node ./src/index.js",
            "build": "rollup -c rollup.config.js"
        },
        "keywords": [
            "文件个数",
            "filenumber",
            "codeline",
            "count"
        ],
        "author": "丁同亚",
        "license": "ISC"
    }
    
    
  3. 写功能代码
  4. 发布 ** 要用npm的官方源 **
     npm login   //登录
     npm publish //发布
    
     更新
     npm version patch
     npm publish
    
     npm version 参数说明
     patch:小变动,比如修复bug等,版本号变动 v1.0.0->v1.0.1
     minor:增加新功能,不影响现有功能,版本号变动 v1.0.0->v1.1.0
     major:破坏模块对向后的兼容性,版本号变动 v1.0.0->v2.0.0
    
    
posted on 2024-11-22 17:11  丁同亚的博客  阅读(26)  评论(0)    收藏  举报