React Native packager.sh: line 11: node: command not found
Asked Answered
F

4

6

I initiated a new project with Create-React-Native-App and then ejected from the project. I followed the instructions for the React-Native docs I opened up a virtual device on Android Studio and ran yarn android to build the app. I then get this error message:

enter image description here

I'm currently using Node 8.11.1 and the command is working normally on my terminal. I installed it with NVM.

In the packager.sh file, this is what line 11 is:

node "./local-cli/cli.js" start "$@"

Here are my .bashrc and .bash_profile files:

.bashrc

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 JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

.bash_profile

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

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

source ~/.bashrc

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

In the virtual device, I get the error message: Unable to load script from assets index.android.bundle. Make sure your bundle is packaged correctly or you're running a packager server

I've found two questions on here related to this problem but one of them was using Nuclide and the other guy was using Xcode. Can someone please help with this issue?

Fulltime answered 29/7, 2018 at 3:4 Comment(3)
Did you install node correctly? Does node -v output anything? How did you install node?Euphroe
Yes I mentioned in my question that I have node working correctly 8.11.1. I installed it with nvmFulltime
Can you try relaunching that Terminal process by quitting the Terminal? Did you add the nvm thing to your PATH?Euphroe
T
24

Answer and discussion from: https://github.com/realm/realm-js/issues/1448#issuecomment-340757479

The default shell that is opened to run this command doesn't have the NVM node in its PATH. The solution given is to link the existing node install to where the shell expects it to be:

ln -s $(which node) /usr/local/bin/node
Twicetold answered 23/10, 2018 at 23:25 Comment(2)
Worked like a charm!Holt
I had to use sudo - it failed silently when I left it out (OSX High Sierra)Conifer
O
1

You can try running below command:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

Reference

Oboe answered 29/7, 2018 at 3:17 Comment(2)
ENOENT: no such file or directory, open 'android/app/src/main/assets/index.android.bundle'Fulltime
Saved my day <3Plenary
K
1

I was facing the same issue and was using nvm. What I need to do is

nvm alias default v8.15.1
Katelynnkaterina answered 20/3, 2019 at 2:49 Comment(0)
J
1

Just to update with someone still having this problem.

I tried all above solutions answer above (and some suggestions from github as well), but neither of them worked for my case (I'm using nvm and node v10.15.3 (TLS))

The final solution I found was to uninstall both nvm & nodejs, then reinstalled nodejs without using nvm via https://nodejs.org/en/download/.

And it works!

Jacklynjackman answered 18/4, 2019 at 10:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.