Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[email protected] returns random port (Docker examples) #87

Closed
danlynn opened this issue Aug 19, 2019 · 5 comments
Closed

[email protected] returns random port (Docker examples) #87

danlynn opened this issue Aug 19, 2019 · 5 comments

Comments

@danlynn
Copy link

danlynn commented Aug 19, 2019

Something changed that is causing portfinder to return random ports instead of the requested port which is open:

docker run --rm -it node:10.16.3 bash
root@0ba5c01217f7:/# npm install [email protected]
npm WARN saveError ENOENT: no such file or directory, open '/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.

+ [email protected]
added 6 packages from 6 contributors and audited 6 packages in 0.999s
found 0 vulnerabilities

root@0ba5c01217f7:/# node
> const PortFinder = require('portfinder');
undefined
> PortFinder.getPort({port: 4200, host: 'localhost'}, function(err, port) {console.debug(`err = ${err}, port = ${port}`)});
undefined
> err = null, port = 21663

> PortFinder.getPort({port: 4200, host: 'localhost'}, function(err, port) {console.debug(`err = ${err}, port = ${port}`)});
undefined
> err = null, port = 26449

Here is the same code running successfully with [email protected]:

docker run --rm -it node:10.16.3 bash
root@55537e7efc22:/# npm install [email protected]
npm WARN saveError ENOENT: no such file or directory, open '/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.

+ [email protected]
added 6 packages from 6 contributors and audited 6 packages in 1.023s
found 0 vulnerabilities

root@55537e7efc22:/# node
> const PortFinder = require('portfinder');
undefined
> PortFinder.getPort({port: 4200, host: 'localhost'}, function(err, port) {console.debug(`err = ${err}, port = ${port}`)});
undefined
> err = null, port = 4200

> PortFinder.getPort({port: 4200, host: 'localhost'}, function(err, port) {console.debug(`err = ${err}, port = ${port}`)});
undefined
> err = null, port = 4200
@fenghuijiuzhuan
Copy link

+1

1 similar comment
@okbeng03
Copy link

+1

@SmithXiong
Copy link

npm install [email protected] revert is ok

@jelhan
Copy link

jelhan commented Aug 19, 2019

This is a duplicate of #84. It should be fixed by #86.

@eriktrom
Copy link
Member

this should be fixed, i rolled back v1.0.23 -> v1.0.21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants