美文网首页
制作npm包

制作npm包

作者: RadishHuang | 来源:发表于2020-07-10 16:49 被阅读0次
  • 首先先新建一个文件夹,文件夹的名字就是包的名字
  • 然后再mynpm里新建一个index.js,内容是暴露出去的方法。
// westore
import store from './utils/store';
import create from './utils/lib/westore/create';
// async
import regeneratorRuntime from './utils/lib/runtime';
// 初始化程序
const init = require('./utils/init');
module.exports = {
  store,
  create,
  regeneratorRuntime,
  init,
}
  • 在终端输入。npm init -y 创建package.json。以后每次发布一次插件,都要修改一次version。让版本不断叠加上去。
{
  "name": "radish_wx_mini_store",
  "version": "1.0.1",
  "description": "小程序store组件",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/radishyell/wx_mini_store.git"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/radishyell/wx_mini_store/issues"
  },
  "homepage": "https://github.com/radishyell/wx_mini_store#readme"
}

  • 上传包到npm。当然首选要有一个npm账号。
  • 在终端上执行npm login。然后输入的用户名是注册的用户名,不是邮箱。
  • 登录成功后npm publish执行发布。最后会有+ radish_wx_mini_store@1.0.1说明发布成功了。
image.png
:wx_mini_store n-321$ npm login
Username: radishhuang
Password: 
Email: (this IS public) 597395959@qq.com
Logged in as radishhuang on https://registry.npmjs.org/.
N-321deMacBook-Pro:wx_mini_store n-321$ npm publish
  
npm notice === Tarball Details === 
npm notice name:          radish_wx_mini_store                    
npm notice version:       1.0.1                                   
npm notice package size:  37.5 kB                                 
npm notice unpacked size: 97.8 kB                                 
npm notice shasum:        02bc287ed0cbfb7a4b0fb85f3be8cc3213e49773
npm notice integrity:     sha512-g9bVRfZYS/0Db[...]yQObpAD+cRCow==
npm notice total files:   26                                      
npm notice 
+ radish_wx_mini_store@1.0.1
N-321deMacBook-Pro:wx_mini_store n-321$ 

相关文章

  • 制作npm包

    首先先新建一个文件夹,文件夹的名字就是包的名字 然后再mynpm里新建一个index.js,内容是暴露出去的方法。...

  • 使用yarn制作npm包

    title: 使用yarn制作npm包date: 2016-10-14 15:35:43tags: Nodethu...

  • 教你开源一个优雅的npm包

    一、注册npm账号 前往https://www.npmjs.com注册一个账号。 二、制作npm包 1.建立一个仓...

  • 如何使用ES6和Babel制作并发布npm包

    今天我们使用Babel来制作并且发布一个简单的npm包 首先在terminal中运行命令npm init,按照提示...

  • 自定义npm包的创建、发布、更新和撤销

    大纲 1、准备2、自定义npm包3、发布自定义npm包4、引用npm包5、更新npm包6、撤销发布的npm包 博客...

  • npm install -s与-d的区别

    npm i 包名 -S =======npm install 包名 --save npm i 包名 -D ====...

  • npm 全局安装包

    npm查看全局安装过的包 npm更新单个全局安装包 npm查看可以更新的全局安装包 npm更新所有全局安装包

  • Node npm操作常用命令行

    安装包npm install 包名 执行即会安装这个包和它所依赖的所有包别名:npm i(简写)npm i 包名@...

  • npm命令

    查看本地某个包 npm ls xxx or npm list xxx 查看本地全部包 npm list --...

  • npm操作

    npm所有者管理: npm登录: npm查看用户信息: 发布(包): npm撤销发布的包: npm退出: 初始化n...

网友评论

      本文标题:制作npm包

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