【发布时间】:2017-08-20 15:10:17
【问题描述】:
当我安装并尝试使用 react-navigation (import {StackNavigator} from 'react-navigation';) 时,我正在尝试 react-native 并得到以下错误。
我使用以下命令安装“react-navigation”:npm install --save react-navigation
在运行上述命令时,我得到 node_modules 文件夹下的 'react-navigation' 文件夹,只有一个文件 (package.json) .以下是文件内容:
{
"_args": [
[
{
"raw": "react-navigation@0.0.0",
"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": "react-navigation@0.0.0",
"_id": "react-navigation@0.0.0",
"_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": "ericvicenti@gmail.com"
},
"_npmVersion": "2.14.7",
"_phantomChildren": {},
"_requested": {
"raw": "react-navigation@0.0.0",
"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": "react-navigation@0.0.0",
"_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": "ericvicenti@gmail.com"
}
],
"name": "react-navigation",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"scripts": {},
"version": "0.0.0"
}
谁能帮我解决这个问题。提前致谢。
【问题讨论】:
-
我可以看看你项目的 package.json
-
每次添加新库时都需要重新启动打包程序,通常这是该错误最常见的问题。
-
@Codesingh 下面是我项目的 package.json { "name": "SimpleApp", "version": "0.0.1", "private": true, "scripts": { "start" :“node node_modules/react-native/local-cli/cli.js start”,“test”:“jest”},“依赖项”:{“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" } }
-
react-navigation 模块没有正确安装。我会尝试删除 node_modules 文件夹,从 package.json 中删除 "react-navigation": "0.0.0",然后再次运行 npm install 和 npm install --save react-navigation。
标签: npm react-native react-navigation