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

Current workspace does not contain React Native projects

Open pt8o opened this issue 7 years ago • 50 comments

Actual Behavior

  • Run React Native: Start Packager
    • "Error while working with workspace: Current workspace does not contain React Native projects. (error code 710)"
  • Run Debug: Start Debugging
    • Debug sidebar shows progress bar for a few seconds then stops
    • Log (Window) says "Error: spawn react-native ENOENT"

Expected Behavior

  • React Native project launches with debugger attached

Software versions

  • React-Native VS Code extension version: 0.9.3
  • VSCode version: 1.34.0
  • OS platform and version: Pop!_OS 19.04
  • NodeJS version: 11.14.0
  • React Native version: 0.58.6
  • Expo SDK version (include if relevant):

Outputs (Include if relevant)

  • Output of the Debug Console (View -> Toggle Debug Console):
(it's empty)
  • Output of the React-Native output channel (View -> Toggle Output -> Select React-Native in ListBox):
[Error] Failed to start the React Native packager (error code 106)

Stack: Error: Failed to start the React Native packager (error code 106): Error while working with workspace: Current workspace does not contain React Native projects. (error code 710)
	at Function.getWrappedError (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/src/common/error/internalError.js:35:16)
	at Function.wrapError (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/src/common/error/errorHelper.js:17:44)
	at handleErrors.resultOfCode.done.reason (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/src/common/entryPointHandler.js:43:72)
	at _rejected (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/node_modules/q/q.js:844:24)
	at /home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/node_modules/q/q.js:870:30
	at Promise.when (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/node_modules/q/q.js:1122:31)
	at Promise.promise.promiseDispatch (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/node_modules/q/q.js:788:41)
	at /home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/node_modules/q/q.js:604:44
	at runSingle (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/node_modules/q/q.js:137:13)
	at flush (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/node_modules/q/q.js:125:13)
	at process._tickCallback (internal/process/next_tick.js:61:11)

  • Output of the Developer Tools console (Help -> Toggle Developer Tools -> Select Console tab):
[Extension Host] debugger listening on port 62927
workbench.main.js:4342 Overwriting grammar scope name to file mapping for scope source.swift.
Old grammar file: file:///usr/share/code/resources/app/extensions/swift/syntaxes/swift.tmLanguage.json.
New grammar file: file:///home/lh/.vscode/extensions/kasik96.swift-0.0.3/syntaxes/swift.tmLanguage
register @ workbench.main.js:4342
workbench.main.js:238 [Extension Host] (node:31773) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
t.log @ workbench.main.js:238
workbench.main.js:2365 Error: Error while working with workspace: Current workspace does not contain React Native projects. (error code 710)
	at Function.getInternalError (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/src/common/error/errorHelper.js:10)
	at Function.selectProject (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/src/extension/commandPaletteHandler.js:332)
	at Function.startPackager (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/src/extension/commandPaletteHandler.js:37)
	at registerVSCodeCommand (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/src/extension/rn-extension.js:181)
	at generate.generator.time (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/src/common/telemetryHelper.js:61)
	at TelemetryGenerator.time (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/src/common/telemetryGenerators.js:54)
	at Function.generate (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/src/common/telemetryHelper.js:61)
	at EntryPointHandler.runFunctionWExtProps (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/src/common/entryPointHandler.js:26)
	at context.subscriptions.push.vscode.commands.registerCommand (/home/lh/.vscode/extensions/msjsdiag.vscode-react-native-0.9.3/src/extension/rn-extension.js:198)
	at d._executeContributedCommand (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:492)
	at d.$executeContributedCommand (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:492)
	at d._doInvokeHandler (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:637)
	at d._invokeHandler (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:637)
	at d._receiveRequest (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:636)
	at d._receiveOneMessage (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:635)
	at define.constructor._protocol.onMessage.e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:633)
	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:47)
	at e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:43)
	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:47)
	at a (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:175)
	at e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:175)
	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:47)
	at y._receiveMessage (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:184)
	at define.constructor._socketDisposables.push._socketReader.onMessage.e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:181)
	at u.fire (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:47)
	at f.acceptChunk (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:178)
	at define.constructor._register._socket.onData.e (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:177)
	at Socket.t (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:186)
	at Socket.emit (events.js:182)
	at addChunk (_stream_readable.js:279)
	at readableAddChunk (_stream_readable.js:264)
	at Socket.Readable.push (_stream_readable.js:219)
	at Pipe.onread (net.js:636)
onDidNotificationChange @ workbench.main.js:2365
workbench.main.js:238 [Extension Host] rejected promise not handled within 1 second: Error: spawn react-native ENOENT
t.log @ workbench.main.js:238
workbench.main.js:238 [Extension Host] stack trace: Error: spawn react-native ENOENT
	at Process.ChildProcess._handle.onexit (internal/child_process.js:229:19)
	at onErrorNT (internal/child_process.js:406:16)
	at process._tickCallback (internal/process/next_tick.js:63:19)
t.log @ workbench.main.js:238
workbench.main.js:1402   ERR spawn react-native ENOENT: Error: spawn react-native ENOENT
	at Process.ChildProcess._handle.onexit (internal/child_process.js:229:19)
	at onErrorNT (internal/child_process.js:406:16)
	at process._tickCallback (internal/process/next_tick.js:63:19)
workbench.main.js:238 [Extension Host] (node:31773) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

pt8o avatar May 22 '19 15:05 pt8o

Apologies if this issue is really vague... I'm just not able to launch a React Native project with the VS Code debugger attached. Regular react-native run-android works fine.

I've confirmed that this same project is working on macOS, so something specific about my Linux environment is making it not recognize the current workspace.

pt8o avatar May 22 '19 15:05 pt8o

Hi @pt8o and thanks for reaching us. Seems to be you are missing global react-native cli. Do you use nvm?

ruslan-bikkinin avatar May 22 '19 15:05 ruslan-bikkinin

Hi @ruslan-bikkinin , yep I use nvm, currently have version 0.34.0.

Also, I did npm install -g react-native-cli, which should have installed it globally, yeah?

In my home directory the react-native command is recognized

$ react-native -v
react-native-cli: 2.0.1
react-native: n/a - not inside a React Native project directory

pt8o avatar May 22 '19 16:05 pt8o

@pt8o the node version is used inside VS Code my differ with the system one which is known issue for VS Code and nvm, and I am suspecting that this is your case. To check please run node -v in system terminal and in VS Code terminal and if node versions are different then simply run nvm alias default YOUR_SYSTEM_NODE_VERSION. After that run npm install -g react-native-cli on system node and restart VS Code.

ruslan-bikkinin avatar May 22 '19 16:05 ruslan-bikkinin

node -v on both system Terminal and VS Code terminal prints v11.14.0

pt8o avatar May 22 '19 16:05 pt8o

And you still can't debug your app after installing React Native cli globally on 11.14.0?

ruslan-bikkinin avatar May 23 '19 09:05 ruslan-bikkinin

It seems that since this extension moved from the "vsmobile.vscode-react-native" to "msjsdiag.vscode-react-native" namespace this is broken.

  • Worked fine before, did not upgrade node, react-native-cli or react-native version
  • Installing latest react-native-cli does not work.
  • Node version: 10
  • No nvm (using brew)
  • react-native -v prints react-native: 0.57.5 so detects valid project

thibmaek avatar May 23 '19 11:05 thibmaek

@thibmaek what version of extension do you use? Do you open exactly the same folder/workspace as before? If you reinstall the extension the problem is still appear?

ruslan-bikkinin avatar May 23 '19 12:05 ruslan-bikkinin

@ruslan-bikkinin correct, react-native-cli is installed globally. react-native -v returns react-native-cli: 2.0.1 on both OS terminal and VS Code terminal. "Start Debugging" or "Start Packager" give the same error messages as above.

pt8o avatar May 23 '19 13:05 pt8o

@pt8o could you please send a screenshot of file structure of workspace you open in VS Code?

ruslan-bikkinin avatar May 23 '19 13:05 ruslan-bikkinin

@ruslan-bikkinin just like this? Screenshot from 2019-05-23 09-45-00

pt8o avatar May 23 '19 13:05 pt8o

Fix for me:

  1. npm cache clean --force
  2. npm i -g react-native-cli@latest
  3. Reinstall extension
  4. Reload VS Code

thibmaek avatar May 23 '19 15:05 thibmaek

@thibmaek thank you for the suggestion, this didn't work for me -- still the same error messages as in the original post

pt8o avatar May 23 '19 17:05 pt8o

Yeah mine stopped working again

thibmaek avatar May 24 '19 08:05 thibmaek

@thibmaek @pt8o guys, could you please open your project in VS Code, then open VS Code terminal, run react-native --version and share output with me? @pt8o also, could you please share .vscode/settings.json content with me?

In general, "Error: spawn react-native ENOENT" signals that react-native command is not available from within VS Code process and it's environment problem.

ruslan-bikkinin avatar May 24 '19 08:05 ruslan-bikkinin

In VS Code terminal Screenshot from 2019-05-24 10-16-35

The full content of .vscode/settings.json is

{
  "editor.insertSpaces": true,
  "editor.tabSize": 2,
  "java.configuration.updateBuildConfiguration": "disabled"
}

pt8o avatar May 24 '19 14:05 pt8o

@pt8o looks like everything is okay there. Could you please run nvm ls and share the output with me?

ruslan-bikkinin avatar May 27 '19 08:05 ruslan-bikkinin

$ react-native --version
react-native-cli: 2.0.1
react-native: 0.57.5
{
  "javascript.validate.enable": false,
  "flow.useNPMPackagedFlow": true
}

thibmaek avatar May 27 '19 11:05 thibmaek

@ruslan-bikkinin nvm ls gives

        v11.0.0
->     v11.14.0
         system
default -> 11 (-> v11.14.0)
node -> stable (-> v11.14.0) (default)
stable -> 11.14 (-> v11.14.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/dubnium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.16.0 (-> N/A)
lts/dubnium -> v10.15.3 (-> N/A)

on both system and VS Code terminals

pt8o avatar May 27 '19 14:05 pt8o

@pt8o are you sure that you don't have any other node installations traces in your system except related to nvm? Also, please check VS Code docs section. Problem described there may seem to be unrelated, but I am guessing the cause of your issue and @thibmaek is the same as there.

ruslan-bikkinin avatar May 27 '19 14:05 ruslan-bikkinin