如何将React-Native组件发布到NPM?

时间:2018-02-21 10:18:54

标签: npm react-native-android

将React-native组件发布到npm后,有哪些步骤? 我试图在NPM中发布样本组件。 我们以前需要建立吗? 如果有,怎么样? 任何人都可以详细说明这些命令吗?

1 个答案:

答案 0 :(得分:0)

不,你不需要构建,只需将android本机代码放在android和ios目录中,将root.in中的index.js重新放置,然后

  • 添加自述文件
  • 提供适当的版本控制
  • 给出正确的姓名

package.json

中这样
  {

      "_from": "package-name@0.1.3",
      "_id": "package-name@0.1.3",
      "_inBundle": false,
      "_location": "/package-name",
      "_phantomChildren": {},
      "_requested": {
        "type": "version",
        "registry": true,
        "raw": "package-name@0.1.3",
        "name": "package-name",
        "escapedName": "package-name",
        "rawSpec": "0.1.3",
        "saveSpec": null,
        "fetchSpec": "0.1.3"
      },
      "_requiredBy": [
        "/"
      ],
      "_spec": "0.1.3",
      "author": {
        "name": "Your name",
        "email": "your@gmail.com"
      },
      "bugs": {
        "url": "https://github.com/bug/issues"
      },
      "dependencies": {
        "prop-types": "^15.6.0"
      },
      "description": "description about pacakge",
      "homepage": "https://github.com/#readme",
      "keywords": [
        "react-native", 
        "react",
        "dnd"
      ],
      "license": "MIT",
      "main": "index.js",
      "name": "package-name",
      "peerDependencies": {},
      "repository": {
        "type": "git",
        "url": "git+https://github.com/package-name.git"
      },
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "version": "0.1.3"
    }