Npm start hangs

Expo CLI 3.4.0 environment info:
System:
OS: macOS High Sierra 10.13.6
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.3 - /usr/local/bin/node
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.4 AI-183.5429.30.34.5452501
Xcode: 9.2/9C40b - /usr/bin/xcodebuild
npmPackages:
expo: ^35.0.0 => 35.0.0
react: 16.8.3 => 16.8.3
react-native: https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz => 0.59.8
npmGlobalPackages:
expo-cli: 3.4.0

Hi, it’s my first time trying expo here. I’m just following the guides to install expo. All is working fine after ‘expo init …’. When i typed npm start, it just hangs at ‘Starting project at …’ then it shows this error
(node:18791) UnhandledPromiseRejectionWarning: RangeError [ERR_SOCKET_BAD_PORT]: Port should be >= 0 and < 65536. Received 65536.
at Server.listen (net.js:1405:13)
at /usr/local/lib/node_modules/expo-cli/node_modules/freeport-async/index.js:8:12
at new Promise ()
at testPortAsync (/usr/local/lib/node_modules/expo-cli/node_modules/freeport-async/index.js:6:10)
at availableAsync (/usr/local/lib/node_modules/expo-cli/node_modules/freeport-async/index.js:24:17)
at Promise (/usr/local/lib/node_modules/expo-cli/node_modules/freeport-async/index.js:37:23)
at new Promise ()
at freePortRangeAsync (/usr/local/lib/node_modules/expo-cli/node_modules/freeport-async/index.js:33:10)
at /usr/local/lib/node_modules/expo-cli/node_modules/freeport-async/index.js:43:18
(node:18791) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:18791) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Anybody knows why ?

Try expo start

have tried. same response also

Hi

It looks like freeport-async thinks that every single port on your machine is currently in use, so it thinks that 65536 (the first number after the last valid port) is the one to use. Since 65536 is not a valid port, you get the above error.

The “hang” is likely the loop where expo checks every port between 19000 and 65535 to see if it’s available.

Can you try downgrading to expo-cli version 3.3.0 or 3.2.3 and see if expo start works then? There was a recent change to freeport-async which was included in expo-cli version 3.4.0, which might have caused this issue.

Hmm. It still hangs also. Have tried downgrading to both 3.3.0 and 3.2.3

Does it still result in the same error message?

First verify that the OS is running the expo binary you think it should be. Run expo --version and verify it’s the version you think you have installed. (Just in case you have two installed and the OS is finding the other one.)

What does this give you?

$ netstat -p tcp -an | grep 1900[0-9]

Post the output like this:

```
output
here
```

Perhaps you could also run freeport-async yourself to see what it says. e.g.:

$ mkdir ports
$ cd ports
$ yarn init
...
$ yarn add freeport-async

Then edit index.js and add the following code:

const freeportAsync = require('freeport-async');
freeportAsync(19000).then(port => {
  console.log(port);
});

Then run it like this to see what port number it finds as the next available:

$ node index.js

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