我一个月前创建了一个反应本机项目,使用create-react-native-app
命令。
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-scripts
,jest-expo
和expo
的版本不同。我的问题是,如何升级版本?我应该只是手动更改版本号吗?
我尝试使用:
$ npm install -g react-native-git-upgrade
$ react-native-git-upgrade
但不会升级版本。
我也尝试了:
$ npm update
$ react-native upgrade
但两个命令都不更新版本。
只是手动更新package.json
文件中的版本和重新运行的npm install
。
因为您正在使用Expo,您也可以使用其升级功能。
因此,只需在根目录中运行expo upgrade
,请在此处查看博览会doc
{
"react-native-scripts": "1.1.0",
"jest-expo": "~19.0.0",
},
尝试使用新版本进行编辑,然后在项目中运行" RM -RF Node_modules& amp; amp; amp; amp; amp; amp; amp; amp;