簡體   English   中英

React Native package.json 版本

[英]React Native package.json versions

我在一個月前使用create-react-native-app命令創建了一個 React Native 項目。

package.json內容如下:

{
  "name": "TestApp2",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "1.1.0",
    "jest-expo": "~19.0.0",
    "react-test-renderer": "16.0.0-alpha.12"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "node node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "expo": "^19.0.0",
    "react": "16.0.0-alpha.12",
    "react-native": "^0.46.1"
  }
}

我今天創建項目的時候, package.json如下:

{
  "name": "NewApp",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "1.5.0",
    "jest-expo": "^21.0.2",
    "react-test-renderer": "16.0.0-alpha.12"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "node node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "expo": "^21.0.0",
    "react": "16.0.0-alpha.12",
    "react-native": "^0.48.4"
  }
}

請注意, react-native-scriptsjest-expoexpo是不同的。 我的問題是,如何升級版本? 我應該手動更改版本號嗎?

我嘗試使用:

$ npm install -g react-native-git-upgrade
$ react-native-git-upgrade

但它不會升級版本。

我也試過:

$ npm update
$ react-native upgrade

但是這兩個命令都不會更新版本。

只需手動更新package.json文件中的版本,然后重新運行npm install

因為你使用的是expo,所以你也可以使用它的升級功能。

所以只需在根目錄中運行expo upgrade ,看這里expo doc

{

"react-native-scripts": "1.1.0",
"jest-expo": "~19.0.0",

},

嘗試使用新版本進行編輯,然后在您的項目中運行“ rm -rf node_modules && npm install”!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM