react native :发布npm库

package.json里可以看到依赖包等库。
在这里插入图片描述自己需要怎么才能使用自己的呢?

一、使用react-native-create-library创建rn项目并修改代码

react-native-create-library : github

# 安装库
npm install -g react-native-create-library
# 查看帮助
react-native-create-library -h
Usage: react-native-create-library [options] <name>

creates a React Native library for different platforms

Options:
  --prefix [prefix]                         The prefix for the library (Default: `RN`) (default: "RN")
  --override-prefix                         Overrides the prefix check and allows the name to begin with uppercase characters
  --module-prefix [modulePrefix]            The module prefix for the library (Default: `react-native`) (default: "react-native")
  --package-identifier [packageIdentifier]  (Android only!) The package name for the Android module (Default: `com.reactlibrary`) (default: "com.reactlibrary")
  --namespace [namespace]                   (Windows only!) The namespace for the Windows module
   (Default: The name as PascalCase)
  --platforms <platforms>                   Platforms the library will be created for. (comma separated; default: `ios,android,windows`) (default: "ios,android,windows")
  -h, --help                                output usage information
ablexq:MyFancyLibrary tmk$ 

# 创建rn项目
# 注意project的名字,需要全部小写,命名规范一定要注意。
react-native-create-library myfancylibrary666 --platforms android,ios

创建完项目,修改代码,依赖,版本号或者名称等。

二、注册npmjs账号

npmjs账号注册

注册完登录看账号是否正常使用:

npmjs账号登录

记得邮箱邮件需要验证。

三、发布:

发布前电脑端需要登录账号:

> npm login
Username: ablexq
Password: 
Email: (this IS public) 776356314@qq.com

进入项目根目录:执行发布即可

> npm publish
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值