Yes
Not relevant.
(Write your answer here if relevant.)
node -v: v9.7.1npm -v: v5.6.0yarn --version (if you use Yarn):npm ls react-scripts (if you haven鈥檛 ejected): Then, specify:
(Write your steps here:)
If it's an error caused by the system configuration, it probably should suggest something meaningful.
This issue has been reported on a bunch of different repositories:
https://github.com/halfzebra/create-elm-app/issues/239
https://github.com/node-modules/detect-port/issues/29
The original maintainer @fengmk2 says it has been fixed in the original detect-port package.
Not available.
A temporary solution:
Looking at create-react-app/packages/react-scripts/scripts/start.js, it appears that you can pass in environment variables:
Set the HOST env variable. e.g. HOST=localhost
And, optionally, also set the PORT=5000 or whatever port you want to use.
I couldn't get the above solution to work, so I just manually edited node_modules/detect-port-alt/lib/detect-port.js and removed the checks around return callback as shown below.
listen(port, host, (err, realPort) => {
// ignore random listening
return callback(err, realPort);
Maybe we need to cherry-pick this fix? https://github.com/node-modules/detect-port/commit/792bccdd4e0ac716ba5fd8c4a0dd0333525b3911
@greglearns most likely this is the solution!
How do we help to cherry-pick that stuff intodetect-port-alt?
@timer might find time to do it
This will be out in 1.1.4.
This is now released in [email protected].
Thanks!
@Timer @greglearns
[email protected] still has the bug
// 1. check specified host (or null)
listen(port, host, (err, realPort) => {
// ignore random listening
if (port === 0) {
return callback(err, realPort);
}
if (err) {
return handleError(err);
}
// 2. check default host
listen(port, null, err => {
if (err) {
return handleError(err);
}
// 3. check localhost <------localhost should be optional, it depends on /etc/hosts
listen(port, 'localhost', err => {
if (err) {
return handleError(err);
}
And what's the difference between detect-port-alt and detect-port? Why not send a PR to dectect-port? If you think it is necessary to fork detect-port so please let us know the repo address then I can make a PR for you.