gpt4 book ai didi

react-native - Visual Studio 代码 react-native : Current workspace is not a React Native project

转载 作者:行者123 更新时间:2023-12-04 15:31:38 25 4
gpt4 key购买 nike

我正在努力尝试使用 Visual Studio 代码和 react-native 设置一个简单的应用程序。我遵循了入门教程 https://github.com/Microsoft/vscode-react-native .我已将所需的扩展安装到 Visual Studio 代码中(主要 react native 工具)。我还设置了各种全局变量(ANDROID_HOME、JAVA_HOME)。我使用 genymotion 作为我的模拟器。

设置好环境后,我使用 react-native-cli 创建了一个 react-native 项目:

react-native init my_project

首先,从 Visual Studio 代码的 Debug 页面,我选择 React-Native 作为我的调试环境。生成一个launch.json 文件。但我看到文件 launchReactNative.js 没有生成。

其次,如果我执行此命令(在 vs 代码中,Ctrl+Shift+p):
React-native: run-android

我收到此消息“当前工作区不是 React Native 项目”

我无法弄清楚我做错了什么。我已经通过 google 和 stackoverflow 进行了搜索,但找不到解决问题的方法。

为什么我的工作区不被识别为 React 原生项目?

这是我的 package.json 文件:
{
"name": "poxx",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "15.4.1",
"react-native": "0.39.2"
},
"devDependencies": {
"babel-jest": "17.0.2",
"babel-preset-react-native": "1.9.0",
"jest": "17.0.3",
"react-test-renderer": "15.4.1"
},
"jest": {
"preset": "react-native"
}
}{
"name": "poxx",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "15.4.1",
"react-native": "0.39.2"
},
"devDependencies": {
"babel-jest": "17.0.2",
"babel-preset-react-native": "1.9.0",
"jest": "17.0.3",
"react-test-renderer": "15.4.1"
},
"jest": {
"preset": "react-native"
}
}

编辑:
File structure

编辑 2:node_modules 中的 react-native 包

enter image description here

最佳答案

这是 react-native-cli@2.0.0 中的一个已知错误并且已经有 PR 等待合并。这应该在 react-native-cli 的下一个版本中修复.目前,解决方法是恢复到早期版本,例如。 react-native-cli@.1.3.0 .

如前所述,您可以使用 npm i -g react-native-cli@1.3.0 安装它。

可以在此处找到有关该错误的更多信息:react-native/issues/11463在这里:vscode-react-native/issues/365

关于react-native - Visual Studio 代码 react-native : Current workspace is not a React Native project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41111065/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com