当我安装并尝试使用react-navigation(从'react-navigation'导入{StackNavigator})时,我尝试了react-native并得到了以下错误。无法解析'react-navigation'
我用下面的命令来安装“反应导航”:NPM安装--save反应导航
在上面的命令运行我得到“反应导航”文件夹node_modules文件夹,只有一个文件(package.json)。以下是该文件的内容:
{
"_args": [
[
{
"raw": "[email protected]",
"scope": null,
"escapedName": "react-navigation",
"name": "react-navigation",
"rawSpec": "0.0.0",
"spec": "0.0.0",
"type": "version"
},
"/Users/rakesh-1812/Documents/REACT_JS/SimpleApp"
]
],
"_from": "[email protected]",
"_id": "[email protected]",
"_inCache": true,
"_location": "/react-navigation",
"_nodeVersion": "4.2.1",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/react-navigation-0.0.0.tgz_1459892254509_0.1584461957681924"
},
"_npmUser": {
"name": "ericvicenti",
"email": "[email protected]"
},
"_npmVersion": "2.14.7",
"_phantomChildren": {},
"_requested": {
"raw": "[email protected]",
"scope": null,
"escapedName": "react-navigation",
"name": "react-navigation",
"rawSpec": "0.0.0",
"spec": "0.0.0",
"type": "version"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/react-navigation/-/react-navigation-0.0.0.tgz",
"_shasum": "1e0f865235cdb4d4aa8086484fd3690ff73df553",
"_shrinkwrap": null,
"_spec": "[email protected]",
"_where": "/Users/rakesh-1812/Documents/REACT_JS/SimpleApp",
"dependencies": {},
"description": "Coming Soon",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "1e0f865235cdb4d4aa8086484fd3690ff73df553",
"tarball": "https://registry.npmjs.org/react-navigation/-/react-navigation-0.0.0.tgz"
},
"maintainers": [
{
"name": "ericvicenti",
"email": "[email protected]"
}
],
"name": "react-navigation",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"scripts": {},
"version": "0.0.0"
}
有人可以帮我解决问题。提前致谢。
我可以看到您的项目的package.json – Codesingh
每次添加新库时都需要重新启动打包程序,通常这是该错误最常见的问题。 –
@Codesingh下面是我的项目的package.json { “名”: “SimpleApp”, “版本”: “0.0.1”, “私”:真实, “脚本”:{ “开始”:“节点node_modules/react-native/local-cli/cli.js start“, ”test“:”jest“ }, ”dependencies“:{ ”react“:”15.4.2“, ”react-native “:”^ 0.42.3“, ”react-navigation“:”0.0.0“ }, ”devDependencies“:{ ”babel-jest“:”19.0.0“, ”babel-preset-react -native“:”1.9.1“, ”jest“:”19.0.2“, ”react-test-renderer “:”15.4.2“ }, }”jest“:{ ”preset“:”react-native“ } } –