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

debug('Listening on ' + bind) doesn't output anything #72

Closed
kevinSuttle opened this issue Apr 16, 2015 · 11 comments
Closed

debug('Listening on ' + bind) doesn't output anything #72

kevinSuttle opened this issue Apr 16, 2015 · 11 comments
Assignees
Labels

Comments

@kevinSuttle
Copy link

In reference to the line in the generated bin/www

function onListening() {
  var addr = server.address();
  var bind = typeof addr === 'string'
    ? 'pipe ' + addr
    : 'port ' + addr.port;
  debug('Listening on ' + bind);
}

I never seem to get any output to my shell from this, even setting:

DEBUG=myapp node /bin/www 
❯ npm run debug

> myapp@0.0.0 debug /Users/kevinsuttle/Code/myapp
> DEBUG=myapp node bin/www

Am I totally doing this wrong?

@dougwilson
Copy link
Contributor

Hi! So the output from the generator itself should have said your environment variable needs to be DEBUG=myapp:*, rather than DEBUG=myapp. Does that work?

@dougwilson dougwilson self-assigned this Apr 16, 2015
@dougwilson
Copy link
Contributor

I'm also assuming your app is actually called "myapp". The generator's own output will tell you the true environment variable to set. From your link, it should have told you DEBUG=generator-socket-4.12.1:*

@kevinSuttle
Copy link
Author

So, in my package.json:

{
  "name": "myapp",
  "main": "app.js",
  "scripts": {
    "start": "node ./bin/www",
    "debug": "DEBUG=myapp node ./bin/www"
  },

In the shell:

DEBUG=myapp:*

In bin/www:

var debug = require('debug')('myapp:server');

@dougwilson
Copy link
Contributor

Ok... We don't add a debug script to the package.json file...

@dougwilson
Copy link
Contributor

What is the output of express --version on your machine?

@kevinSuttle
Copy link
Author

Yeah the debug was mine. No one uses it anyway. Will delete.

❯ express --version
4.12.1

@dougwilson
Copy link
Contributor

But otherwise, it should print out following the debug command the generatory tool should have displayed to you:

DEBUG=myapp:* node ./bin/www

(note that :* that you were missing from your initial question).

@kevinSuttle
Copy link
Author

Yeah, I just don't see this output anything to the shell:

  debug('Listening on ' + bind);

@dougwilson
Copy link
Contributor

I'm not having that issue here. Can you send me the complete application you are trying to use (upload to like a Github repo)? Creating a new application here works perfectly:

$ express myapp

   create : myapp
   create : myapp/package.json
   create : myapp/app.js
   create : myapp/public
   create : myapp/public/images
   create : myapp/public/stylesheets
   create : myapp/public/stylesheets/style.css
   create : myapp/views
   create : myapp/views/index.jade
   create : myapp/views/layout.jade
   create : myapp/views/error.jade
   create : myapp/bin
   create : myapp/bin/www
   create : myapp/routes
   create : myapp/routes/index.js
   create : myapp/routes/users.js

   install dependencies:
     $ cd myapp && npm install

   run the app:
     $ DEBUG=myapp:* ./bin/www

   create : myapp/public/javascripts

$ cd myapp
$ npm install
debug@2.1.3 node_modules\debug
└── ms@0.7.0

cookie-parser@1.3.4 node_modules\cookie-parser
├── cookie-signature@1.0.6
└── cookie@0.1.2

morgan@1.5.2 node_modules\morgan
├── basic-auth@1.0.0
├── depd@1.0.1
└── on-finished@2.2.0 (ee-first@1.1.0)

serve-favicon@2.2.0 node_modules\serve-favicon
├── fresh@0.2.4
├── parseurl@1.3.0
├── ms@0.7.0
└── etag@1.5.1 (crc@3.2.1)

body-parser@1.12.3 node_modules\body-parser
├── content-type@1.0.1
├── raw-body@1.3.4
├── bytes@1.0.0
├── qs@2.4.1
├── depd@1.0.1
├── on-finished@2.2.0 (ee-first@1.1.0)
├── iconv-lite@0.4.8
└── type-is@1.6.1 (media-typer@0.3.0, mime-types@2.0.10)

express@4.12.3 node_modules\express
├── fresh@0.2.4
├── merge-descriptors@1.0.0
├── cookie-signature@1.0.6
├── cookie@0.1.2
├── methods@1.1.1
├── escape-html@1.0.1
├── utils-merge@1.0.0
├── range-parser@1.0.2
├── content-type@1.0.1
├── finalhandler@0.3.4
├── parseurl@1.3.0
├── vary@1.0.0
├── serve-static@1.9.2
├── depd@1.0.1
├── content-disposition@0.5.0
├── path-to-regexp@0.1.3
├── on-finished@2.2.0 (ee-first@1.1.0)
├── qs@2.4.1
├── etag@1.5.1 (crc@3.2.1)
├── send@0.12.2 (destroy@1.0.3, ms@0.7.0, mime@1.3.4)
├── proxy-addr@1.0.7 (forwarded@0.1.0, ipaddr.js@0.1.9)
├── type-is@1.6.1 (media-typer@0.3.0, mime-types@2.0.10)
└── accepts@1.2.5 (negotiator@0.5.1, mime-types@2.0.10)

jade@1.9.2 node_modules\jade
├── character-parser@1.2.1
├── commander@2.6.0
├── void-elements@2.0.1
├── mkdirp@0.5.0 (minimist@0.0.8)
├── with@4.0.3 (acorn-globals@1.0.4, acorn@1.0.3)
├── constantinople@3.0.1 (acorn-globals@1.0.4)
└── transformers@2.1.0 (promise@2.0.0, css@1.0.8, uglify-js@2.2.5)

$ DEBUG=myapp:* ./bin/www
  myapp:server Listening on port 3000 +0ms

I don't know what else to say.

@kevinSuttle
Copy link
Author

Weird. It just started working on myapp. Rubber-duck debugging at its finest.

Tried this one, and fine as well. https://github.com/kevinSuttle/express-generator-socket

Thanks anyway, @dougwilson. Wish I could point to something that changed so that future people that stumble upon this could have something useful. :/

@dougwilson
Copy link
Contributor

Hm, that's really weird. I really hate that too :( Typically I usually lock complete issues on GitHub, but I'm leaving this open in case you find out what it was and want to post here :)

cwonrails pushed a commit to cwonrails/generator that referenced this issue Apr 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants