我使用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-scripts
,jest-expo
和expo
的版本不同。我的问题是,我该如何升级版本?我应该手动更改版本号吗?
我试图使用:
$ npm install -g react-native-git-upgrade
$ react-native-git-upgrade
但它没有升级版本。
我也尝试过:
$ npm update
$ react-native upgrade
但这两个命令都不会更新版本。
答案 0 :(得分:1)
只需手动更新package.json
文件中的版本并重新运行npm install
。
答案 1 :(得分:-1)
{
"react-native-scripts": "1.1.0",
"jest-expo": "~19.0.0",
},
尝试使用新版本进行编辑,然后在项目中运行“rm -rf node_modules&& npm install”!