在一个package.json中匹配react,react-dom和react-native的版本

时间:2017-09-07 09:53:09

标签: reactjs react-native react-dom

我想要做的是,在一个项目中,我可以同时使用react-native和react,所以我需要一个package.json的想法, 这是我的package.json:

{
  "name": "reactNativeWeb",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "create-ios-bundle": "react-native bundle --entry-file index.ios.js --bundle-output ./bundle/bundle_iOS/index.ios.bundle --platform ios --assets-dest ./bundle/bundle_iOS --dev false",
    "create-android-bundle": "react-native bundle --entry-file index.android.js --bundle-output ./bundle/bundle_android/index.android.bundle --platform android --assets-dest ./bundle/bundle_android --dev false",
    "web-dev": "webpack-dev-server --config web/config/webpack.config.dev.js --inline --hot --colors",
    "web-prod": "webpack --config web/config/webpack.config.prod.js --progress --colors",
    "test": "jest"
  },
  "dependencies": {
    "react": "15.5.4",
    "react-dom": "15.5.4",
    "react-native": "0.46.0"
  },
  "devDependencies": {
    "babel-preset-es2015": "6.24.1",
    "babel-preset-react-native": "2.0.0",

    "autoprefixer": "7.1.2",
    "babel-core": "6.25.0",
    "babel-eslint": "7.2.3",
    "babel-jest": "20.0.3",
    "babel-loader": "7.1.1",
    "babel-preset-react-app": "^3.0.2",
    "babel-runtime": "6.26.0",
    "case-sensitive-paths-webpack-plugin": "2.1.1",
    "chalk": "1.1.3",
    "css-loader": "0.28.4",
    "dotenv": "4.0.0",
    "eslint": "4.4.1",
    "eslint-config-react-app": "^2.0.0",
    "eslint-loader": "1.9.0",
    "eslint-plugin-flowtype": "2.35.0",
    "eslint-plugin-import": "2.7.0",
    "eslint-plugin-jsx-a11y": "5.1.1",
    "eslint-plugin-react": "7.1.0",
    "extract-text-webpack-plugin": "3.0.0",
    "file-loader": "0.11.2",
    "fs-extra": "3.0.1",
    "fsevents": "1.1.2",
    "html-webpack-plugin": "2.29.0",
    "jest": "20.0.4",
    "object-assign": "4.1.1",
    "postcss-flexbugs-fixes": "3.2.0",
    "postcss-loader": "2.0.6",
    "promise": "8.0.1",
    "react-dev-utils": "^4.0.1",
    "style-loader": "0.18.2",
    "sw-precache-webpack-plugin": "0.11.4",
    "url-loader": "0.5.9",
    "webpack": "3.5.1",
    "webpack-dev-server": "2.7.1",
    "webpack-manifest-plugin": "1.2.1",
    "whatwg-fetch": "2.0.3"
  }
}

并且这个配置可以成功运行react.js,但它无法运行react-native,所以我需要帮助,因为react-native需要反应版本16.0.0-alpha.12,但react-dom不依赖在这个版本上,我怎样才能找到合适的配置呢?

请帮助,谢谢。

2 个答案:

答案 0 :(得分:0)

你想要达到的目标有点不清楚。

如果您正在尝试使用react-native创建一个Web应用程序,我认为您错了。 react-native可让您使用javascript构建跨平台的移动应用。

如果您尝试升级本机反应项目,请查看here

如果您正在尝试启动一个新的反应项目,那么您应该使用here提到的方法之一。您无需手动安装react和react-dom。

答案 1 :(得分:0)

谢谢大家。我修理它。在项目中成功运行Web应用程序和react-native app,这是项目:

react-native-web