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

React native command palette doesn't work.

Open dominictwlee opened this issue 8 years ago • 35 comments

Actual Behavior

  1. Current Workspace is not a React Native project.

Expected Behavior

  1. Expect react native to run on android simulator.

Software versions

  • React-Native VS Code extension version: 0.6.13
  • VSCode version: 1.25.1
  • OS platform and version: Ubuntu 16.04
  • NodeJS version: 10.4.0
  • React Native version: 0.56.0
  • Expo SDK version (include if relevant):

Outputs (Include if relevant)

  • (View -> Output):
[Error] Failed to start the React Native packager

Stack: Error: Failed to start the React Native packager: Current workspace is not a React Native project.
    at Function.getWrappedError (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/error/internalError.js:35:16)
    at Function.wrapError (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/error/errorHelper.js:18:44)
    at resultOfCode.done.reason (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/entryPointHandler.js:43:72)
    at _rejected (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:844:24)
    at /home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:870:30
    at Promise.when (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:1122:31)
    at Promise.promise.promiseDispatch (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:788:41)
    at /home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:604:44
    at runSingle (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:137:13)
    at flush (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
[Error] Failed to run the application in Android

Stack: Error: Failed to run the application in Android: Current workspace is not a React Native project.
    at Function.getWrappedError (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/error/internalError.js:35:16)
    at Function.wrapError (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/error/errorHelper.js:18:44)
    at resultOfCode.done.reason (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/entryPointHandler.js:43:72)
    at _rejected (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:844:24)
    at /home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:870:30
    at Promise.when (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:1122:31)
    at Promise.promise.promiseDispatch (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:788:41)
    at /home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:604:44
    at runSingle (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:137:13)
    at flush (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
[Error] Failed to run the application in Android

Stack: Error: Failed to run the application in Android: Current workspace is not a React Native project.
    at Function.getWrappedError (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/error/internalError.js:35:16)
    at Function.wrapError (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/error/errorHelper.js:18:44)
    at resultOfCode.done.reason (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/entryPointHandler.js:43:72)
    at _rejected (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:844:24)
    at /home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:870:30
    at Promise.when (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:1122:31)
    at Promise.promise.promiseDispatch (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:788:41)
    at /home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:604:44
    at runSingle (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:137:13)
    at flush (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/node_modules/q/q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
  • Output (Developer Tools Console)
notificationsAlerts.ts:40 Error: Current workspace is not a React Native project.
    at Function.selectProject (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/extension/commandPaletteHandler.js:283:29)
    at Function.runAndroid (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/extension/commandPaletteHandler.js:87:21)
    at registerVSCodeCommand (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/extension/rn-extension.js:160:215)
    at generator.time (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/telemetryHelper.js:61:41)
    at TelemetryGenerator.time (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/telemetryGenerators.js:54:18)
    at Function.generate (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/telemetryHelper.js:61:26)
    at EntryPointHandler.runFunctionWExtProps (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/common/entryPointHandler.js:26:75)
    at context.subscriptions.push.vscode.commands.registerCommand (/home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13/src/extension/rn-extension.js:180:34)
    at e._executeContributedCommand (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:697:706)
    at e.$executeContributedCommand (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:698:212)
    at e._doInvokeHandler (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:658:87)
    at e._invokeHandler (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:657:779)
    at e._receiveRequest (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:656:851)
    at e._receiveOneMessage (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:656:620)
    at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:655:544
    at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:658:673
    at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:96:599
    at e.fire (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:97:917)
    at u (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:159:721)
    at Socket.<anonymous> (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:159:898)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)

dominictwlee avatar Jul 23 '18 21:07 dominictwlee

Hi @dominictwlee Could you please open terminal in your VSCode and execute react-native -v and paste output here.

Thanks!

itoys avatar Jul 24 '18 06:07 itoys

Sure, It's:

react-native-cli: 2.0.1
react-native: 0.56.0

dominictwlee avatar Jul 24 '18 22:07 dominictwlee

Hi @dominictwlee what directory do you open? Is it root of react native project?

ruslan-bikkinin avatar Jul 25 '18 07:07 ruslan-bikkinin

@ruslan-bikkinin Yep, root of react-native project created with react-native init. react-native run-android works, but none of the commands in vscode are working.

dominictwlee avatar Jul 25 '18 12:07 dominictwlee

@dominictwlee that's insteresting. Could you please try to run any extension command that leads to error and paste here Debug Console output?

ruslan-bikkinin avatar Jul 25 '18 13:07 ruslan-bikkinin

@ruslan-bikkinin The only messages I get are from the Developer tools console and output as shown in my 1st post.

dominictwlee avatar Jul 25 '18 19:07 dominictwlee

@dominictwlee I could reproduce your problem by installing react-native package (not react-native-cli!) globally and then by executing React Native > Run Packager command. In this case:

  1. Please, check that you have installed react-native-cli package globally, not react-native.
  2. If you are using nvm, please check that node versions that are available in VS Code and in system terminal are the same. Sometimes that could be a root of problems.

Please let us know if it helps you.

ruslan-bikkinin avatar Jul 26 '18 10:07 ruslan-bikkinin

@ruslan-bikkinin So node version has to match the one shown here? vsnode

Or do you mean node -v shows the same version in both system and vscode terminal? If so, yes they both show the same version which is 10.4.0 in my situation.

And yes, I'm using react-native-cli installed globally.

dominictwlee avatar Jul 26 '18 10:07 dominictwlee

@dominictwlee could you please show screenshot of your project opened in VS Code after error being occured?

ruslan-bikkinin avatar Jul 26 '18 10:07 ruslan-bikkinin

react-native

@ruslan-bikkinin

dominictwlee avatar Jul 26 '18 21:07 dominictwlee

@dominictwlee What extensions, among React Native Tools, do you have installed?

ruslan-bikkinin avatar Jul 27 '18 07:07 ruslan-bikkinin

@ruslan-bikkinin screenshot from 2018-07-27 08-57-44 screenshot from 2018-07-27 08-56-55

dominictwlee avatar Jul 27 '18 07:07 dominictwlee

@dominictwlee Could you please check your settings(both user and workspace settings). https://code.visualstudio.com/docs/getstarted/settings Especially react-native-tools.projectRoot

itoys avatar Jul 27 '18 08:07 itoys

@iTOYS react-native-tools.projectRoot is using the default "".

My other settings are:

{
    "workbench.colorTheme": "Material Theme",
    "files.autoSave": "off",
    "editor.tabSize": 2,
    "editor.wordWrap": "on",
    "editor.formatOnSave": true,
    "window.zoomLevel": 0,
    "emmet.syntaxProfiles": {
        "javascript": "javascriptreact"
    },
    "files.associations": {
        "*.js": "javascriptreact"
    },
    "workbench.iconTheme": "eq-material-theme-icons",
    "materialTheme.fixIconsRunning": false,
    "workbench.statusBar.visible": true,
    "workbench.activityBar.visible": true,
    "prettier.requireConfig": true,
    "terminal.integrated.fontSize": 15,
    "typescript.validate.enable": false,
    "typescript.format.enable": false,
    "javascript.validate.enable": false,
    "emmet.triggerExpansionOnTab": true,
    "flow.useNPMPackagedFlow": true
}

dominictwlee avatar Jul 27 '18 14:07 dominictwlee

@dominictwlee what is the full path to package.json file? Seems to be that problem line is https://github.com/Microsoft/vscode-react-native/blob/2c82a3f990836260c11640db528a30590867bb8a/src/common/reactNativeProjectHelper.ts#L25

and fs.existsSync method in your case unexpectedly returns false. It is hard to say what's wrong in your particular case, so the only thing that I can suggest you is to try to debug extension itself on your side. The instructions for that are the following:

  1. Run these commands in terminal: git clone https://github.com/Microsoft/vscode-react-native.git cd vscode-react-native npm i -g gulp && npm i
  2. Open extension project in VS Code, then run Quick Extension + Debugger debug configuration: image. It should start new VS Code instance and debugger for the extension. You should see message like [/media/rbikkinin/work/projects/vscode-react-native]: Overwriting extension /home/rbikkinin/.vscode/extensions/vsmobile.vscode-react-native-0.6.13 with /media/rbikkinin/work/projects/vscode-react-native..
  3. Set breakpoint at vscode-react-native/src/common/reactNativeProjectHelper.ts:25
  4. In just opened VS Code instance open you app directory and execute Run Packager command.
  5. Wait until breakpoint being hit and try to find out why your problem happens.

ruslan-bikkinin avatar Jul 27 '18 15:07 ruslan-bikkinin

@ruslan-bikkinin Got this message when I completed tasks 1 and 2, any ideas why?

screenshot from 2018-07-29 18-08-40

Should I go ahead and click debug anyway?

dominictwlee avatar Jul 29 '18 17:07 dominictwlee

@dominictwlee Did you restart vscode after 1, 2 steps? Seems to be that it couldn't find quick-build task, that is defined in gulpfile.js. You can check whether it exists by clicking Tasks -> Run tasks... and wait a little bit for VSCode processing.

ruslan-bikkinin avatar Jul 30 '18 07:07 ruslan-bikkinin

I'm getting this in the console output: Gulp is not installed on your system. Run npm install -g gulp to install it.

The only thing I can think of is that vscode isn't detecting the folder where nvm saves it's global modules.

Any ideas?

dominictwlee avatar Jul 30 '18 21:07 dominictwlee

@dominictwlee You can try to remove node_modules/.bin folder.

ruslan-bikkinin avatar Jul 31 '18 07:07 ruslan-bikkinin

@ruslan-bikkinin Deleted node_modules/.bin file, and the same warning still popped up so I clicked Debug anyway.

2nd VScode popped up with message [/home/domtwlee/Projects/vscode-react-native]: Overwriting extension /home/domtwlee/.vscode/extensions/vsmobile.vscode-react-native-0.6.13 with /home/domtwlee/Projects/vscode-react-native..

unverified-breakpoints

Unverified breakpoints when attempting to set them on the 1st vscode window where debugger is running.

listontimeout This shows up when I click on debugger restart. Breakpoints can only be set on timers.js and net.js.

dominictwlee avatar Jul 31 '18 22:07 dominictwlee