Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 460
avatarhzh Avatar asked Jul 29 '18 03:07

avatarhzh


People also ask

What is the path of the React Native library in cellar?

from above output you can clearly see the path: /usr/local/Cellar/node/6.1.0/libexec/npm/bin/react-native

How to solve SH - command not found after running NPM start?

So in this article, we are going to learn how to solve sh: react-scripts: command not found after running npm start - this error. This type of error normally happens because it is missing node_modules. Check that if you have the node_modules folder in your root folder. If not run these commands in your terminal:

Why does NPX React-Native init hang in my system?

If you run into issues where running npx react-native init hangs in your system, try running it again in verbose mode and referring to #2797 for common causes: Issue caused by the number of directories inotify (used by watchman on Linux) can monitor. To solve it, run this command in your terminal window

How to fix NPM warn locking error EACCES while using React Native CLI?

If you encounter an error such as npm WARN locking Error: EACCES while using the React Native CLI, try running the following: If you added React Native manually to your project, make sure you have included all the relevant dependencies that you are using, like RCTText.xcodeproj, RCTImage.xcodeproj.


2 Answers

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
like image 105
tlrjbrnnn Avatar answered Oct 13 '22 15:10

tlrjbrnnn


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

nvm alias default v8.15.1
like image 39
Chirag Purohit Avatar answered Oct 13 '22 14:10

Chirag Purohit