Error installing the Expo CLI, running command "npm install expo-cli --global"

Viewed 266

I'm trying to start a React Native application, But when I try to install the Expo CLI running any of the commands below, it returns this error:

npm WARN config global --global, --local are deprecated. Use --location=global instead.
npm ERR! Unexpected token '.'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Amro\AppData\Local\npm-cache_logs\2022-07-21T18_29_03_950Z-debug-0.log

Commands tried:
"npm install expo-cli --global"
"npm install --global expo-cli"
"npm install expo-cli --location=global"

If anybody has any suggestion on how to install the Expo CLI, I would very much appreciate it, thanks.

2 Answers

Have you tried installing without the global tag?

npm install expo-cli

I started a blank project and this worked fine.

Triple check you are in the correct file location when running the command. If you are new to expo/npm/etc, double check you are using correct versions of Node.js and Npm, as well as having correctly set up environment variables. Please reply to this comment if this doesn't work and you have further questions.

As of Expo v46 the CLI is part of the local expo package. There is no need to install the global package.

Use npx expo start to start your app.
npx will look in the node_modules of your current directory first, and because the expo package includes the expo-cli bin it will be invoked.

This makes maintaining older apps MUCH easier.
Details in the blog post.

The New Expo CLI
blog image

Related