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

@dominictwlee Could you please try to delete nvm and install nodejs directly.

Thanks!

itoys avatar Aug 01 '18 09:08 itoys

@dominictwlee Also you can try to set default node version by executing nvm alias default NEEDED_VERSION. In some cases like yours that could be the cause.

ruslan-bikkinin avatar Aug 01 '18 11:08 ruslan-bikkinin

@iTOYS @ruslan-bikkinin

Tried setting nvm alias default and didn't make a difference.

So what I did was comment out nvm commands from my .bashrc and installed nodejs directly.

debugger is working and projectRoot is showing up as "/home/domtwlee/Projects/testDebugger" which is the right path.

So are you saying that vscode-react-native is incompatible with nvm?

dominictwlee avatar Aug 01 '18 19:08 dominictwlee

@dominictwlee No exactly, I use nvm as well during my development on Ubuntu including debugging RN apps and extension - just in your particular case something goes wrong. Could you please do the following:

  • run nvm ls in system terminal and in VS Code integrated terminal and show us the output?
  • run cat ~/.npmrc, cat ~/.bashrc, cat ~/.bash_profile and show us the output?

ruslan-bikkinin avatar Aug 02 '18 08:08 ruslan-bikkinin

nvm ls in both vscode terminal and system terminal:

nvm-ls

.npmrc:

//registry.npmjs.org/:_authToken=AUTH_TOKEN_HERE

.bashrc:
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
    else
        color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi
export PATH=$HOME/bin:$PATH

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

export PATH="$HOME/.yarn/bin:$PATH"


# tabtab source for serverless package
# uninstall by removing these lines or running `tabtab uninstall serverless`
[ -f /home/domtwlee/.nvm/versions/node/v10.4.0/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.bash ] && . /home/domtwlee/.nvm/versions/node/v10.4.0/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.bash
# tabtab source for sls package
# uninstall by removing these lines or running `tabtab uninstall sls`
[ -f /home/domtwlee/.nvm/versions/node/v10.4.0/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.bash ] && . /home/domtwlee/.nvm/versions/node/v10.4.0/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.bash

export ANDROID_HOME=$HOME/Software/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

My .bash_profile is empty.

dominictwlee avatar Aug 02 '18 21:08 dominictwlee

@dominictwlee all seems to be in order here. How do you run VS Code? Could you please try to run it from terminal via code and let us know if issue still persists? Also, please, make sure that you have no remains of another node instances in your path which have been installed not via nvm (potential directories are /usr/bin, usr/local/bin and so on).

ruslan-bikkinin avatar Aug 07 '18 10:08 ruslan-bikkinin

@ruslan-bikkinin I managed to get it to work by doing nvm use default && code in the main terminal, but it stops working everytime I reload/open a folder/open a workspace. Any solutions to this? Because I can see this becoming really annoying.

dominictwlee avatar Aug 10 '18 22:08 dominictwlee

@dominictwlee I think that this is mostly vscode and nvm issue rather than extension one, because all we do in extension that is lead to the problem you described in first post is running a react-native -v command by childProcess.spawn("react-native",["-v"], { cwd: YOUR_RPOJECT_DIRECTORY }) . In your case it fails because seems to be that there is no available react-native command in PATH. I have no clues for now, why nvm doesn't work in your case, I'd recommend you to do the following steps that I did when I was trying to make nvm works on my machine:

  1. Remove nvm and any other node instances that could be installed.
  2. Install nvm
  3. Run the following commands in system terminal, considering that v10.4.0 is your main node version:
nvm install v10.4.0
nvm use v10.4.0
nvm alias default v10.4.0
  1. Install other node versions via nvm if needed

ruslan-bikkinin avatar Aug 13 '18 11:08 ruslan-bikkinin

@dominictwlee do you have a chance to look at it?

ruslan-bikkinin avatar Aug 16 '18 14:08 ruslan-bikkinin

@ruslan-bikkinin Yeah tried that, still have to declare nvm use default and launch code from terminal in order for things to work. I guess that'll have to do for now.

dominictwlee avatar Aug 16 '18 21:08 dominictwlee

@dominictwlee could you please submit issue in vscode repo and share the link here? As soon as you've done that, I'll join to discussion there.

ruslan-bikkinin avatar Aug 20 '18 08:08 ruslan-bikkinin

@dominictwlee I am going to close this due to you already have an issue in vscode and we still don't have any strong evidence that the extension causes your problem. Also, please take a look at my recent comment https://github.com/Microsoft/vscode/issues/56890#issuecomment-436650669.

ruslan-bikkinin avatar Nov 14 '18 14:11 ruslan-bikkinin

I fixed by running

nvm alias default v10.16.0

this changed default from pointing node (which is latest installed version by default) to straight on 10.16

FoodlyEric avatar Jun 03 '19 21:06 FoodlyEric

I fixed this by change my wifi to use my phone 4G. But when i change my wifi to office.The problem also with me. So i don't know what the question now!!

iosToTop avatar Apr 29 '20 06:04 iosToTop

Hi @iosToTop, please open a new issue according to our issue template and describe your problem in details.

RedMickey avatar Apr 29 '20 07:04 RedMickey