我正在尝试使用以下命令运行一个react本机应用程序。
npm run android我得到以下错误。

im使用nvm - nvm use stable
现在使用节点v8.9.4 (npm v4.6.1)
**package.json**
{
"name": "client",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-native-scripts": "1.11.0",
"jest-expo": "23.0.0",
"react-test-renderer": "16.0.0"
},
"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": "^23.0.4",
"react": "16.0.0",
"react-native": "0.50.3"
}
}另一个不同的解决方案建议重新运行构建过程,因为可能存在一些干扰,但这对我不起作用。
发布于 2018-01-26 19:59:13
我自己设法解决了这个问题。错误消息显示了react-native版本的0.50.3。
但从https://facebook.github.io/react-native/versions.html可以看到,最新的版本是0.52。
因此,我更新了json包以反映这一点。
"dependencies": {
"react-native": "0.52"
}然后我删除了npm模块并重新运行npm install。这解决了我的问题。
更新package.json react-native依赖项以反映最新版本。
发布于 2018-01-27 00:40:37
我也有同样的问题,可汗给了我们正确的解决方案。
我在这里为那些需要修复的人提供了package.json:
{
"name": "project",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-native-scripts": "1.11.0",
"jest-expo": "25.0.0",
"react-test-renderer": "16.0.0"
},
"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": "^25.0.0",
"react": "16.0.0",
"react-native": "0.52"
}
}https://stackoverflow.com/questions/48460452
复制相似问题