0

I am trying to start my first React Native project (https://facebook.github.io/react-native/docs/getting-started.html). The first command it says to do on this page is

npm install -g expo-cli

Which produces the following ERROR message .

npm WARN checkPermissions Missing write access to /Users/~/.npm-packages/lib/node_modules/expo-cli/node_modules/ansi-escapes
.
.
.
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/~/.npm-packages/lib/node_modules/expo-cli/node_modules/ansi-escapes'
npm ERR! If you believe this might be a permissions issue, please double-check the permissions of the file and its containing directories, or try running the command again as root/Administrator (though this is not recommended).

So I used the sudo command:

 sudo npm install -g expo-cli

This command successfully passed, outputting some warnings (i.e. skipping optional dependencies):

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/ngrok-bin-freebsd-ia32@2.2.8 (node_modules/expo-cli/node_modules/@expo/ngrok-bin-freebsd-ia32):
.
.
.
+ expo-cli@2.7.0
updated 2 packages in 13.452s

Then, as the React Native page instructs, I run this command to use expo:

expo init

Here is the result:

zsh: command not found: expo

I tried the same thing with "expo start" and have spent over two hours researching this problem, to no avail. Thank you very much.

~ represents the username

Y. Moondhra
  • 195
  • 2
  • 12

1 Answers1

1

After hours, of researching and experimenting I found the solution:

  1. uninstall node and npm completely: https://stackoverflow.com/a/11178106/9687684
  2. download nvm https://github.com/creationix/nvm and get it to work. For me, I had to create a file (linux command: touch ~/.bash_profile) add these lines of code to the source file:

     export NVM_DIR="~/.nvm"
    source ~/.nvm/nvm.sh
    [ -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                                                             
    
  3. Run these linux commands. I used to have to do sudo npm install -g expo-cli, which would install expo-cli, but I would not be able to use expo-cli / the expo command:

    nvm install node
    nvm use --delete-prefix v11.9.0
    npm install -g expo-cli
    

=D

Y. Moondhra
  • 195
  • 2
  • 12