2

There are questions and answers dealing with the new www file in the folder bin for express 4. However I could not find the current question: Why eventhough www is a javascript file, it does not have the js extension?

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
  • No reason it couldn't be..., also see https://stackoverflow.com/questions/36638123/learning-node-js-express-js-whats-the-deal-with-bin-www?rq=1 for why it is bin\www – Cody G Dec 06 '18 at 04:22
  • so no special reason it does not have the extension? Could it work the same if it is `www.js`? – KansaiRobot Dec 06 '18 at 04:32
  • Yeah it's definitely not a requirement, you might have to change your `npm start` script from `node bin/www` to `node bin/www.js` but maybe not even that – Cody G Dec 06 '18 at 04:35

1 Answers1

3

I imagine that the maintainer of express uses many executable shell scripts, which are generally left without the extension. And since you're executing this as a node script, it is also an executable. See https://askubuntu.com/questions/503127/should-i-save-my-scripts-with-the-sh-extension

You can add the extension, everything should still work.

And as an aside, the reason for using the bin/www instead of running app.js directly: Learning node.js/express.js: What's the deal with bin/www?

Cody G
  • 8,368
  • 2
  • 35
  • 50