- Output of the React-Native output channel (View -> Toggle Output -> Select React-Native in ListBox):
PASTE OUTPUT HERE
- Output of the Developer Tools console (Help -> Toggle Developer Tools -> Select Console tab):
PASTE OUTPUT HERE
```
this was literally working the other day even after the new 0.2.4 tools update. then all of sudden i started getting this error.
creating a new project as an empty test and same thing is happening...
I had the same experience around the same time about December 10th 2014.
I uninstalled vscode deleted my global npm modules uninstalled NPM., everything I could find and started from scratch. As with @mikepaggi if happens with all projects. I actually was so desperate I switched to an old machine where it was working. And then it happened there too. Could have upgraded anything in my package.json, like react-native. A little new to NPM and VSCode and ReactNative.
Can someone explain what else to delete to do a clean install and start from scratch?
I deleted the app the local projects and
usrlocallibnode_modules
In addition to inability to start the debugger I'm also seeing Error: Current workspace is not a React Native project. messages now. Maybe this is related?
If your workspace is not detected as a react-native project, then that would cause this error. We require a communication channel between the debugger and the extension process, and if we don't think we are in a react-native project then we don't set up that communication channel.
When you open your project, do you see a .vscode/.react folder and a .vscode/launchReactNative.js file created in your project? If not, that suggests that we don't believe you are in a react-native project and you'll run into this issue.
Could you please go to the root of your project on the command line and run react-native -v and let us know what the result is? We run that command and expect to get back something like react-native: 0.39.2 to indicate that we are within a react-native project.
Note that there's currently a bug where if you open an individual file rather than a folder, we'll throw errors when trying to start our extension, but the intended behavior in that case is to simply not activate since we require a workspace.
I'm not opening an individual file. I'm opening the directory using code . command from the terminal.
This is weird. For every new project created using react-native init I'm now getting the following:
$ react-native -v
react-native-cli: 2.0.0
react-native: n/a - not inside a React Native project directory
But there is the [email protected] package installed in node_modules. All usual commands like react-native run-ios or building/releasing the app using XCode works ๐
So this might be a problem with RN cli then.
.vscode/.react
.vscode/launchReactNative.js
No, I don't have those in new projects. Didn't saw the usual toast from RN tools in vscode neither.
Looks like you're right: my react-native-cli version is 1.0.0 and it works as I expect, while if I use [email protected] it fails in the way that you specify. In the short term, if you npm install -g [email protected] then our extension should work, but I don't know what they've changed in react-native-cli between 1.0.0 and 2.0.0
@MSLaguana can you check if react-native-cli 1.2.0 works for you?
Looks like it should:
$ react-native -v
react-native-cli: 1.2.0
react-native: 0.39.2
Found the problem and there is already a PR with a fix. Next release of react-native-cli should be ok. Workaround for now is to revert to 1.3.0
If @mikepaggi confirms that 1.3.0 works for him (works for me) then this can be closed.
my saviors :-)
all fixed and now the launchReactNative.js and .react folders are created automatically i see!
Looks like a good work around! Thanks so much!
Before :
$ react-native -v
react-native-cli: 2.0.0
not a react-native root (or something like that)
And after:
$ react-native -v
react-native-cli: 1.3.0
react-native: 0.38.1
The the steps I took:
npm uninstall -g react-native-cli
npm install -g [email protected]
And restart VSCode too or else the error was still present.
@grahamp 's solution worked for me too :) ๐
i was having react-native-cli version 1.2.0
All was good with this, but when one day i created a new project and when wanted to start the VS Code debugger, it came up with this error.
[Error] "Could not debug. Unable to set up communication with VSCode react-native extension. Is this a react-native project, and have you made sure that the react-native npm package is installed at the root?
๐ Thanks guys ! it's now working.
There should also be a new release [email protected] which also works as well now.
I'm still having this issue with VSCode 1.8.1, node 7.4.0 , on a project folder created by react native init with react-native-cli 2.0.1 installed globally.
react-native-cli: 2.0.1
react-native: 0.40.0
Then after launching Debug Android the error.
[Error] "Could not debug. Unable to set up communication with VSCode react-native extension. Is this a react-native project, and have you made sure that the react-native npm package is installed at the root?"
Running react-native run-android works just fine.
I installed react-native-cli globally via npm, not via yarn, is this an issue?
Using npm should be fine; as long as you can react-native -v to get the output you showed then it should be sufficient. When you open the project in vscode, do you see it create a .vscode/.react folder?
Nop, no .vscode/.react folder there.
A sex, 20/01/2017, 21:16, Jimmy Thomson notifications@github.com escreveu:
Using npm should be fine; as long as you can react-native -v to get the
output you showed then it should be sufficient. When you open the project
in vscode, do you see it create a .vscode/.react folder?โ
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode-react-native/issues/365#issuecomment-274182025,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABmOhAYuJQityS-vcNZmzzM59gYPjXINks5rUSQtgaJpZM4LJ8Md
.
That suggests that our extension is not activating then. Are you opening a folder, not an individual file, and does that folder contain the package.json of a react-native project?
I am opening the react project folder, I see all the files in the left
explorer pane package.json is at root level.
A sex, 20/01/2017, 22:26, Jimmy Thomson notifications@github.com escreveu:
That suggests that our extension is not activating then. Are you opening a
folder, not an individual file, and does that folder contain the
package.json of a react-native project?โ
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode-react-native/issues/365#issuecomment-274196689,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABmOhIhlt0hUQ7QnAdMtzzQDdYlR9f8Jks5rUTSfgaJpZM4LJ8Md
.
Can you please go to "Help -> Toggle developer tools" in vscode, and see if the console shows any errors/messages?
Here's something interesting in the log
shell.ts:541Error while executing command 'react-native.cmd -v'e.onUnexpectedError @ shell.ts:541
extensionHost.ts:293 [Extension Host] ApplicationInsights:Sender [Object]
Then again after executing "React Native: Run Android"
shell.ts:541 Error while executing command 'react-native.cmd -v'
e.onUnexpectedError @ shell.ts:541
(anonymous function) @ shell.ts:457
e.onUnexpectedError @ errors.ts:68
o @ errors.ts:88
t.onUnexpectedExtHostError @ mainThreadErrors.ts:13
e.handle @ abstractThreadService.ts:34
s @ ipcRemoteCom.ts:269
f @ ipcRemoteCom.ts:226
_combinedTickCallback @ internal/process/next_tick.js:67
_tickCallback @ internal/process/next_tick.js:98
FYI, I'm able to call rect-native from the VSCode internal terminal
D:\reactn\test>react-native -v
react-native-cli: 2.0.1
react-native: 0.40.0
I don't know if this is relevant, but I cant call react-native.cmd it throws me an error. Calling any other .bin script with .cmd prefix work just fine like eslint.cmd or even react-native-git-upgrade.cmd.
D:\reactn\test>react-native.cmd
The system cannot find the path specified.
Both files are present in the global npm path as shown by wherecommand
C:\Users\rui\AppData\Roaming\npm\react-native
C:\Users\rui\AppData\Roaming\npm\react-native.cmd
Seeing this problem in my React Native 0.40.0 project. When I run react-native -v, I see error: unkown option -v.
Looks like the command has changed to a capital -V or --version. react-native -V prints: 0.40.0
Odd, -v works for me in clean project, created w/ 0.40:
~/sandbox/bar react-native -v
react-native-cli: 1.2.0
react-native: 0.40.0
and
~/sandbox/bar react-native -v
react-native-cli: 2.0.1
react-native: 0.40.0
Weeeird. I think my -V is incorrect. I looked on react-native's repo and found no trace of the change.
And now that I'm on a different machine, -v works as expected. I'll report in if I figure out why -V was the option on my personal machine after work today.
On the machine that is giving the error, can you check whether your global install is of react-native, or react-native-cli? I believe that if you accidentally globally install react-native then it responds to -V as you mention.
I did the following
react-native init testThe results are the same Current workspace is not a React Native project.
Here is my package.json file
{
"name": "test",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "~15.4.0-rc.4",
"react-native": "0.40.0"
},
"devDependencies": {
"babel-jest": "18.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "18.1.0",
"react-test-renderer": "~15.4.0-rc.4"
},
"jest": {
"preset": "react-native"
}
}
Again, ran reac-native run-android from the embedded terminal and everything worked as advertised.
@ruimgoncalves can you please open a node command prompt, navigate to your project folder, open an interactive node session, and try running
var p = child_process.spawn("react-native.cmd", ["-v"]);
p.stdout.on("data", function (data) { console.log("Output: " + data.toString());})
p.on("error", function (err) { console.log("ERROR"); console.log(err);})
Hopefully that can give a more specific reason for why we can't run the command for you.
Eureka!!
So the problem was a file named react-native.cmd.cmd that was in my node installation directory.
D:\reactn\test>where react-native.cmd
C:\Program Files\nodejs\react-native.cmd.cmd
C:\Users\rui\AppData\Roaming\npm\react-native.cmd
Deleting the react-native.cmd.cmd file solved the issue for me, thanks!!!
Hah, did not expect that. Glad you've got that sorted out now :)
The local react-native package doesn't understand -v however the react-native-cli package does.
My problem was that the local react-native was in my path before the global:
./node_modules/.bin:/Users/craigmorris/.config/yarn/global/node_modules/.bin
For this to work the global path needs to be come before the local path:
/Users/craigmorris/.config/yarn/global/node_modules/.bin:./node_modules/.bin
I've been having this issue a lot the past two days.
My solution is simple: Restarting VSC has been fixing it for me.
It looks like .vscode/.react isn't being generated until I do a restart.
I had kind of this issue as well, although running on [email protected]. Nothing above worked for me and it got me crazy. So I'll leave my solution here, if anyone else runs into this problem:
It all started with that I was using PowerShell instead of the command prompt and so I did not realize that the react-native.cmd didn't work until i finally tried it with the command prompt. The where react-native command was just working fine but directly calling the command didn't.
The problem was my PATH variable was messed up. It had a stray double quote (") in it. (Actually it wasn't in the PATH variable itself but in a variable that is used in the PATH variable. So check that too!)
The issue for me is when i am opening with code . from command line, react native extension is working, but if i am reopening the project from start menu, it is not working
@prijindal are you on Windows? What shell are you using? It's possible (actually people have been running into this many times) that the path to react-native executable is being added to global PATH variable at shell startup and hence available only inside of shell. When running VSCode from Start menu (or Dock on Mac) it just not able to find react-native executable and hence fails to activate
I am using arch linux
but that might be the case, I am adding yarn bin directory to PATH in my .bashrc
@VickyKoblinski 's solution works for me. I just restarted the vscode and it works without doing anything else. Strange...
Most helpful comment
I've been having this issue a lot the past two days.
My solution is simple: Restarting VSC has been fixing it for me.
It looks like .vscode/.react isn't being generated until I do a restart.