我试图将React Native与Visual Studio Code一起使用(应该是最好的)但是当我尝试调试时它会给我一个错误。
我已经安装了React Native Tools扩展,但是当我尝试启动时(F5)它返回" [错误]无法调试。确定反应原生的npm包安装在根目录下? "
我也尝试用F1">发送命令。 React Native:运行Android"但它返回错误"当前工作空间不是React Native项目。"
我使用的是Ubuntu 16.04 LTS。
Visual Studio Code 1.11.2
react-native-cli:2.0.1
反应原生:0.43.3
你们有没有使用Visual Studio Code?你有这些问题吗?
我的launch.json(扩展React Native Tools生成的唯一文件)
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Android",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "android",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug iOS",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "ios",
"target": "iPhone 5s",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Attach to packager",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "attach",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug in Exponent",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
}
]
}
答案 0 :(得分:0)
我猜这个答案有点迟了。
您的问题是vscode无法在您的PATH引用中找到react-native。
如果您使用npm安装它,请尝试以下操作:
npm install react-native --global
这应该安装在你的路径中。重启vscode,你应该好好去。
答案 1 :(得分:0)
我认为这是PATH问题,请安装并使用:
npm i react-native -g