Cannot start app with error: node_modules/expo/AppEntry.js: Unexpected token '.'

I cannot run the app, just throw an error: node_modules/expo/AppEntry.js: Unexpected token ‘.’, but I try to find in the AppEntry.js and don’t have any unexpected

Environment

Expo CLI 4.12.1 environment info:
System:
OS: macOS 11.6
Shell: 5.8 - /bin/zsh
Binaries:
Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
Yarn: 1.22.11 - /usr/local/bin/yarn
npm: 6.13.4 - ~/.nvm/versions/node/v12.14.1/bin/npm
Watchman: 2021.09.13.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7678000
Xcode: 13.0/13A233 - /usr/bin/xcodebuild
npmPackages:
expo: ^41.0.0 => 41.0.1
react: 16.13.1 => 16.13.1
react-dom: 16.13.1 => 16.13.1
react-native: https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz => 0.63.2
npmGlobalPackages:
expo-cli: 4.12.1
Expo Workflow: managed

node_modules/expo/AppEntry.js contains this:

import registerRootComponent from 'expo/build/launch/registerRootComponent';

import App from '../../App';

registerRootComponent(App);

It basically just imports your app from App.js. The unexpected ‘.’ might be in your App.js.

I get somewhat the same issue any how the error appears after trying to run either npm i -g expo-cli or npx expo-cli -h. And the project has not been set-up yet.

That doesn’t really make sense. The title of this post implies that the error happens when trying to start the app. Presumably with something like npx expo start.

npm i -g expo-cli and npx expo-cli -h do not start the app. They don’t have anything to do with any particular Expo app.

Can you please copy and past from the console showing the command you are running and the error you’re getting? Or screenshots? Also, what version of the Expo SDK are you using? The OP was using Expo SDK 41 which is pretty old now.

Sure, I found out that basically I had to downgrade the node version for Windows.
This is what I was trying:

PS C:\Users\myuser\Documents\GitHub> npm install -g expo-cli
npm ERR! Unexpected token '.'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\myuser\AppData\Local\npm-cache\_logs\2023-05-30T21_29_50_254Z-debug-0.log

Sorry if it might have been inconvenient.

1 Like