1

I am trying to get started with React Native development.

I have installed Node, create-react-native-app and git. When initializing a new React Native project, I use the command sudo create-react-native-app my-first-app, but I keep on getting the question to install expo-cli globally:

*****:dev *****$ sudo create-react-native-app my-first-app
Password:
$This command requires Expo CLI.
Do you want to install it globally [Y/n]? y
Installing the package 'expo-cli'...
Expo CLI installed. You can run `expo --help` for instructions.
This command requires Expo CLI.
Do you want to install it globally [Y/n]? y
Installing the package 'expo-cli'...
Expo CLI installed. You can run `expo --help` for instructions.
This command requires Expo CLI.
Do you want to install it globally [Y/n]? y
Installing the package 'expo-cli'...
Expo CLI installed. You can run `expo --help` for instructions.
This command requires Expo CLI.
Do you want to install it globally [Y/n]? N

This keeps on repeating...

When running expo --help, I get -bash: expo: command not found, even after installing expo-cli manually.

Anybody an idea what could help resolving this issue?

System information:

MacOS 10.14.4
Node v10.15.3
npm 6.4.1
stijnpiron
  • 359
  • 2
  • 4
  • 15
  • Have you tried without sudo as I believe that is not necessary. – gerwin May 10 '19 at 22:02
  • Without sudo, he also tries to install expo-cli, but then I get all these permission denied issues: `npm ERR! Error: EACCES: permission denied, access '/Users/*****/npm-global/lib/node_modules/expo-cli'` – stijnpiron May 11 '19 at 07:53
  • And what if you install expo-cli yourself with sudo and then execute create-react-native-app? – gerwin May 11 '19 at 08:02
  • This has the same result. Tried create-react-native-app both with and without sudo, with sudo: keeps trying to install expo-cli globally, without sudo: permission errors. After installing expo-cli globally: `updated 1 package in 38.384s` – stijnpiron May 11 '19 at 19:26
  • It seems the underlying problem is a permissions error. A user-based npm install should be able to do all of this without any super user permissions. I'd try reinstalling npm in full and make sure you can download and install other packages as well. Try installing it using brew if you didn't before but make sure to purge the old install fully. – gerwin May 11 '19 at 20:12
  • That also didn't work... Was tired of trying, so did a clean installation of my MacBook and now everything works. Thanks anyway for helping! – stijnpiron May 21 '19 at 13:28

1 Answers1

1

I know this isn't going to be of much help but I was having the exact same issue and I was needing to do a reinstall anyway but that sorted the issue so I'm assuming this is a bash profile issue or if you're using ohhmyzsh a .zshrc config issue. unfortunately, beyond that, I'm unsure why npm stopped setting this up automatically.

After a bit of looking about it sounds like an environment issue. Your computer needs to know where to look for programmes when you run them. If you moved things around during install, it is possible that your computer isn’t looking in the right place.

To see whether my assumption is correct, first check if /users/me/.npm-global/bin is in your path.

echo $PATH

If it isn’t there, you will need to add it to the path. Open up ~/.bash_profile then add the following line to the bottom:

# NPM global installs
export PATH=$PATH:~/.npm-global/bin

Finally, back in the shell, type:

source ~/.bash_profile

Hopefully that will have fixed your problem

Chris Marshall
  • 740
  • 1
  • 9
  • 25