vscode-react-native icon indicating copy to clipboard operation
vscode-react-native copied to clipboard

[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?

Open mikepaggi opened this issue 9 years ago • 37 comments

Actual Behavior

  1. Get 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?"".
  2. I've already uninstalled the plugin and reinstalled it and still same issue.

Expected Behavior

  1. Expect it to start debugger

Software versions

  • React-Native VS Code extension version: 0.2.4
  • VSCode version: 1.7.2
  • OS platform and version: macOS 10.12.1
  • NodeJS version: 6.7.1
  • React Native version:0.39.1

Outputs (Include if relevant)

  • Output of the Debug Console (View -> Toggle Debug Console): [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? PASTE OUTPUT HERE
- 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

mikepaggi avatar Dec 11 '16 14:12 mikepaggi

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.

mikepaggi avatar Dec 11 '16 15:12 mikepaggi

creating a new project as an empty test and same thing is happening...

mikepaggi avatar Dec 11 '16 17:12 mikepaggi

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 \usr\local\lib\node_modules

grahamp avatar Dec 14 '16 06:12 grahamp

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?

jsynowiec avatar Dec 14 '16 08:12 jsynowiec

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.

MSLaguana avatar Dec 14 '16 18:12 MSLaguana

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.

MSLaguana avatar Dec 14 '16 18:12 MSLaguana

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.

jsynowiec avatar Dec 14 '16 18:12 jsynowiec

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 avatar Dec 14 '16 18:12 MSLaguana

@MSLaguana can you check if react-native-cli 1.2.0 works for you?

jsynowiec avatar Dec 14 '16 18:12 jsynowiec

Looks like it should:

$ react-native -v
react-native-cli: 1.2.0
react-native: 0.39.2

MSLaguana avatar Dec 14 '16 18:12 MSLaguana

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.

jsynowiec avatar Dec 14 '16 19:12 jsynowiec

my saviors :-)

all fixed and now the launchReactNative.js and .react folders are created automatically i see!

mikepaggi avatar Dec 14 '16 22:12 mikepaggi

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 avatar Dec 15 '16 07:12 grahamp

@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.

s2zaman avatar Dec 20 '16 07:12 s2zaman

There should also be a new release [email protected] which also works as well now.

MSLaguana avatar Dec 20 '16 16:12 MSLaguana

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?

ruimgoncalves avatar Jan 20 '17 19:01 ruimgoncalves

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?

MSLaguana avatar Jan 20 '17 21:01 MSLaguana

Nop, no .vscode/.react folder there.

A sex, 20/01/2017, 21:16, Jimmy Thomson [email protected] 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 .

ruimgoncalves avatar Jan 20 '17 22:01 ruimgoncalves

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?

MSLaguana avatar Jan 20 '17 22:01 MSLaguana

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 [email protected] 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 .

ruimgoncalves avatar Jan 20 '17 22:01 ruimgoncalves