无法解析 'react-navigation'
Unable to resolve 'react-navigation'
当我安装并尝试使用 react-navigation(从 'react-navigation' 导入 {StackNavigator};)时,我正在尝试 react-native 并遇到以下错误。
Error
我使用以下命令安装 "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"
}
谁能帮我解决这个问题。提前致谢。
您必须停止您的节点服务器并重新启动它。
去做:
sudo lsof -n -i4TCP:8081 | grep LISTEN
它将侦听端口 8081 上 运行ning 的服务。默认情况下,在其上响应本机服务器 运行s。然后,执行下面的命令杀死服务器进程。
kill -9 <cma process id>
最后,运行 您的项目再次
react-native run-ios
在项目文件夹中
React 导航仍处于测试阶段。当我使用命令时它对我有用:
npm install --save react-navigation@1.0.0-beta.7
这是最新版本。 https://github.com/react-community/react-navigation/releases
我无法安装 react-native,尝试了互联网上的所有方法。使用 Yarn 而不是 npm 解决了问题。
尝试安装 react-navigation 堆栈,npm i react-navigation-stack
。然后import {createStackNavigator} from 'react-navigation-stack'
停止服务器并再次运行您的项目。
当我安装并尝试使用 react-navigation(从 'react-navigation' 导入 {StackNavigator};)时,我正在尝试 react-native 并遇到以下错误。
Error
我使用以下命令安装 "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"
}
谁能帮我解决这个问题。提前致谢。
您必须停止您的节点服务器并重新启动它。
去做:
sudo lsof -n -i4TCP:8081 | grep LISTEN
它将侦听端口 8081 上 运行ning 的服务。默认情况下,在其上响应本机服务器 运行s。然后,执行下面的命令杀死服务器进程。
kill -9 <cma process id>
最后,运行 您的项目再次
react-native run-ios
在项目文件夹中
React 导航仍处于测试阶段。当我使用命令时它对我有用:
npm install --save react-navigation@1.0.0-beta.7
这是最新版本。 https://github.com/react-community/react-navigation/releases
我无法安装 react-native,尝试了互联网上的所有方法。使用 Yarn 而不是 npm 解决了问题。
尝试安装 react-navigation 堆栈,npm i react-navigation-stack
。然后import {createStackNavigator} from 'react-navigation-stack'
停止服务器并再次运行您的项目。