Unable to initialise first expo project!

I have downloaded node and npm and checked the version of both. Both are installed. However, when i typed ‘sudo npm install -g expo-cli’ and ‘expo init HelloWorld’, it states that zsh: command not found: expo

  • expo-cli@3.11.7

updated 1 package in 46.401s

rachelchng@Rachels-MacBook-Air 01 % expo -v

zsh: command not found: expo

rachelchng@Rachels-MacBook-Air 01 % expo cli-v

zsh: command not found: expo

rachelchng@Rachels-MacBook-Air 01 % expo-cli-v

zsh: command not found: expo-cli-v

rachelchng@Rachels-MacBook-Air 01 % cd Desktop/rn/01

cd: no such file or directory: Desktop/rn/01

rachelchng@Rachels-MacBook-Air 01 % expo init Hello

zsh: command not found: expo

rachelchng@Rachels-MacBook-Air 01 %

Please help!! Thanks so much. Ive been study for many weeks at this installation.

1 Like

Hi

It seems that npm installed the expo command to a directory that is not in your PATH environment variable.

If you type npm bin -g it should print out the path where it installed the expo command. This path should be added to your PATH environment variable.

In theory you should be able to do this by adding something like the following at the end of you .zshrc file in your home directory:

export PATH=$PATH:$(npm bin -g)

but I’ve never used ZSH, so am not 100% sure that will do what you want.

I suggest you try the above, then close your Terminal window and open a new one. Then try running expo again.

If the above doesn’t work for you, try this:

Create a new file in /etc/paths.d called npm. The file should contain only the path to npm’s global bin directory (as printed out by npm bin -g). Then close and reopen your Terminal and try running expo again.

Thanks for helping!!!

Ok, I followed your instruction and I typed ‘npm bin -g’ into terminal and got this.
“/usr/local/Cellar/node/13.6.0/bin
(not in PATH env variable)”

Now I’m trying to follow your next step of adding ‘export PATH=$PATH:$(npm bin -g)’ at the end of the .zshrc file.

But… I have no idea how to do that. How do i find my .zshrc file?

Really really appreciate your help wodin :slight_smile:

Hi

Please note that you left out the dollar signs in the code I put in my comment :slight_smile:

But! I see you used Homebrew to install node. I did too, so I’m not sure why your PATH is not already set up in a way that would work for expo.

What do you get if you type the following commands one after the other?

brew --prefix
ls -l /usr/local/bin/expo*
echo $PATH
ls -l ~/.zshrc ~/.zlogin ~/.zshenv ~/.zprofile

EDIT: I’ve found this post that suggests .zprofile is a better place to update the PATH for zsh.

I also found this article about zsh configuration in case you’re interested in more details of what configuration files zsh uses in what order and under what circumstances.

Hi wodin,

I typed in what you said and pasted the outcome below. Not really sure what to make of it though

rachelchng@Rachels-Air ~ % npm bin -g

/usr/local/Cellar/node/13.6.0/bin

(not in PATH env variable)

rachelchng@Rachels-Air ~ % brew --prefix

/usr/local

rachelchng@Rachels-Air ~ % ls -l /usr/local/bin/expo*

zsh: no matches found: /usr/local/bin/expo*

rachelchng@Rachels-Air ~ % echo $PATH

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

rachelchng@Rachels-Air ~ % ls -l ~/.zshrc ~/.zlogin ~/.zshenv ~/.zprofile

ls: /Users/rachelchng/.zlogin: No such file or directory

ls: /Users/rachelchng/.zprofile: No such file or directory

ls: /Users/rachelchng/.zshenv: No such file or directory

ls: /Users/rachelchng/.zshrc: No such file or directory

Thanks!

OK, one more thing, please?

echo $ZDOTDIR

That might print a blank line or else the name of a directory.

If it prints the name of a directory, do this:

echo 'export PATH=$PATH:$(npm bin -g)' >> $ZDOTDIR/.zprofile

Make sure it has the dollar signs and uses two greater than signs with no space between them and that the two single quote characters are normal single quote characters. Not fancy quotes or backticks. Copying and pasting from my comment should do the trick.

If echo $ZDOTDIR prints a blank line, then do this instead:

echo 'export PATH=$PATH:$(npm bin -g)' >> ~/.zprofile

Then close and reopen your Terminal.

Now if you type echo $PATH you should see that you have /usr/local/Cellar/node/13.6.0/bin added to the end of your PATH.

If you run expo --version now it should work.

1 Like

THANK YOU SO MUCH WODIN!!!
I’ve been stuck at this issue for the past 2 weeks!!!
Thanks for your patience and guidance :grin: :smile: :smile: :grin:

1 Like

I got through the first hurdle of being able to initialise my first Expo project, named Hello.

However, tragically, when I tried ‘npm start’, I faced a whole bunch of errors.

Is it so tough for everyone too… Please advise :confused:

Thanks very much in advance!

**

Last login: Sun Jan 19 18:06:05 on ttys000

(not in PATH env variable)

rachelchng@Rachels-MacBook-Air ~ % cd Desktop/rn/01/Hello

rachelchng@Rachels-MacBook-Air Hello % npm start

@ start /Users/rachelchng/Desktop/rn/01/Hello

expo start

Starting project at /Users/rachelchng/Desktop/rn/01/Hello

^[[AExpo DevTools is running at http://localhost:19002

Opening DevTools in the browser… (press shift-d to disable)

Your project is in SDK version >= 33.0.0, but the expo package version seems to be older.

Error: React Native is not installed. Please run npm install in your project directory.

Couldn’t start project. Please fix the errors and restart the project.

Set EXPO_DEBUG=true in your env to view the stack trace.

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! @ start: expo start

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the @ start script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! /Users/rachelchng/.npm/_logs/2020-01-19T10_07_34_052Z-debug.log

rachelchng@Rachels-MacBook-Air Hello % npm start

Hi

The error indicates that the app’s dependencies have not been installed for some reason. This normally happens during expo init, though, so it’s strange. (No, it’s not always so difficult :slight_smile:)

What output do you get when you run expo init? Also, what do you get when you run expo diagnostics within the app’s root directory (i.e. the directory where app.json and package.json live, e.g. /Users/rachelchng/Desktop/rn/01/Hello).

To install the dependencies you can run the following from within your app’s root directory:

npm install

By the way if you want to post error messages etc. on the forums without losing the formatting you can paste them in like this:

```
output
here
```

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.