Why .bin/www is consider as a javascript file without the .js extention when I use express-generator
Why is .bin/www considered a javascript file without the .js extention when I use express-generator?
Every time I create a folder bin/ with a www file inside, it's not considered a JavaScript file (which is normal because the .js extention is missing)
javascript express
add a comment |
Why is .bin/www considered a javascript file without the .js extention when I use express-generator?
Every time I create a folder bin/ with a www file inside, it's not considered a JavaScript file (which is normal because the .js extention is missing)
javascript express
add a comment |
Why is .bin/www considered a javascript file without the .js extention when I use express-generator?
Every time I create a folder bin/ with a www file inside, it's not considered a JavaScript file (which is normal because the .js extention is missing)
javascript express
Why is .bin/www considered a javascript file without the .js extention when I use express-generator?
Every time I create a folder bin/ with a www file inside, it's not considered a JavaScript file (which is normal because the .js extention is missing)
javascript express
javascript express
edited Dec 31 '18 at 14:05
braaterAfrikaaner
1,085517
1,085517
asked Dec 31 '18 at 14:01
S7_0S7_0
3822620
3822620
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
First of all, the file is marked "executable" by express-generator:
-rwxr-xr-x 1 samihult staff 1591 Dec 31 16:07 www
Secondly, it starts with a "hashbang" line, which tells what interpreter to use:
#!/usr/bin/env node
I don't know if I should create a new post or not but. What is the purpose of putting a hashbang + marked the file as "executable" instead of just creating a .js file ?
– S7_0
Jan 2 at 9:34
They are just ways of marking the file executable (and telling how it should be executed). You can runwww
directly from the command line. Strictly speaking, it does not say that the contents is JavaScript,.js
extension would imply that more; but it's customary to not have (file format) extensions in executables.
– Sami Hult
Jan 2 at 9:44
Putting .js will tell you how it should be executed too (using node or your browser) and it still can be run directly from the command line. So what a .js extension would imply ?
– S7_0
Jan 5 at 12:38
1
These are all just conventions, nothing more, and some of them are overlapping.node
command does not care about the extension, nor does it care if the file is executable or has hashbang or not - it assumes javascript contents. A browser, on the other hand, is more interested about the mime-type of the file, but can use the extension to determine its type as well. A script will be loaded using e.g.script
tag, and in that case, also the script tag attributes will play role (browsers don't like hashbang lines, they are for command line shells).
– Sami Hult
Jan 5 at 12:58
In short:.js
extension hints you, your editor and your browser what the file type is, but there are plenty of other factors and strategies that are used to determine file type in addition.
– Sami Hult
Jan 5 at 13:00
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53988314%2fwhy-bin-www-is-consider-as-a-javascript-file-without-the-js-extention-when-i-u%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
First of all, the file is marked "executable" by express-generator:
-rwxr-xr-x 1 samihult staff 1591 Dec 31 16:07 www
Secondly, it starts with a "hashbang" line, which tells what interpreter to use:
#!/usr/bin/env node
I don't know if I should create a new post or not but. What is the purpose of putting a hashbang + marked the file as "executable" instead of just creating a .js file ?
– S7_0
Jan 2 at 9:34
They are just ways of marking the file executable (and telling how it should be executed). You can runwww
directly from the command line. Strictly speaking, it does not say that the contents is JavaScript,.js
extension would imply that more; but it's customary to not have (file format) extensions in executables.
– Sami Hult
Jan 2 at 9:44
Putting .js will tell you how it should be executed too (using node or your browser) and it still can be run directly from the command line. So what a .js extension would imply ?
– S7_0
Jan 5 at 12:38
1
These are all just conventions, nothing more, and some of them are overlapping.node
command does not care about the extension, nor does it care if the file is executable or has hashbang or not - it assumes javascript contents. A browser, on the other hand, is more interested about the mime-type of the file, but can use the extension to determine its type as well. A script will be loaded using e.g.script
tag, and in that case, also the script tag attributes will play role (browsers don't like hashbang lines, they are for command line shells).
– Sami Hult
Jan 5 at 12:58
In short:.js
extension hints you, your editor and your browser what the file type is, but there are plenty of other factors and strategies that are used to determine file type in addition.
– Sami Hult
Jan 5 at 13:00
add a comment |
First of all, the file is marked "executable" by express-generator:
-rwxr-xr-x 1 samihult staff 1591 Dec 31 16:07 www
Secondly, it starts with a "hashbang" line, which tells what interpreter to use:
#!/usr/bin/env node
I don't know if I should create a new post or not but. What is the purpose of putting a hashbang + marked the file as "executable" instead of just creating a .js file ?
– S7_0
Jan 2 at 9:34
They are just ways of marking the file executable (and telling how it should be executed). You can runwww
directly from the command line. Strictly speaking, it does not say that the contents is JavaScript,.js
extension would imply that more; but it's customary to not have (file format) extensions in executables.
– Sami Hult
Jan 2 at 9:44
Putting .js will tell you how it should be executed too (using node or your browser) and it still can be run directly from the command line. So what a .js extension would imply ?
– S7_0
Jan 5 at 12:38
1
These are all just conventions, nothing more, and some of them are overlapping.node
command does not care about the extension, nor does it care if the file is executable or has hashbang or not - it assumes javascript contents. A browser, on the other hand, is more interested about the mime-type of the file, but can use the extension to determine its type as well. A script will be loaded using e.g.script
tag, and in that case, also the script tag attributes will play role (browsers don't like hashbang lines, they are for command line shells).
– Sami Hult
Jan 5 at 12:58
In short:.js
extension hints you, your editor and your browser what the file type is, but there are plenty of other factors and strategies that are used to determine file type in addition.
– Sami Hult
Jan 5 at 13:00
add a comment |
First of all, the file is marked "executable" by express-generator:
-rwxr-xr-x 1 samihult staff 1591 Dec 31 16:07 www
Secondly, it starts with a "hashbang" line, which tells what interpreter to use:
#!/usr/bin/env node
First of all, the file is marked "executable" by express-generator:
-rwxr-xr-x 1 samihult staff 1591 Dec 31 16:07 www
Secondly, it starts with a "hashbang" line, which tells what interpreter to use:
#!/usr/bin/env node
answered Dec 31 '18 at 14:08
Sami HultSami Hult
2,3421613
2,3421613
I don't know if I should create a new post or not but. What is the purpose of putting a hashbang + marked the file as "executable" instead of just creating a .js file ?
– S7_0
Jan 2 at 9:34
They are just ways of marking the file executable (and telling how it should be executed). You can runwww
directly from the command line. Strictly speaking, it does not say that the contents is JavaScript,.js
extension would imply that more; but it's customary to not have (file format) extensions in executables.
– Sami Hult
Jan 2 at 9:44
Putting .js will tell you how it should be executed too (using node or your browser) and it still can be run directly from the command line. So what a .js extension would imply ?
– S7_0
Jan 5 at 12:38
1
These are all just conventions, nothing more, and some of them are overlapping.node
command does not care about the extension, nor does it care if the file is executable or has hashbang or not - it assumes javascript contents. A browser, on the other hand, is more interested about the mime-type of the file, but can use the extension to determine its type as well. A script will be loaded using e.g.script
tag, and in that case, also the script tag attributes will play role (browsers don't like hashbang lines, they are for command line shells).
– Sami Hult
Jan 5 at 12:58
In short:.js
extension hints you, your editor and your browser what the file type is, but there are plenty of other factors and strategies that are used to determine file type in addition.
– Sami Hult
Jan 5 at 13:00
add a comment |
I don't know if I should create a new post or not but. What is the purpose of putting a hashbang + marked the file as "executable" instead of just creating a .js file ?
– S7_0
Jan 2 at 9:34
They are just ways of marking the file executable (and telling how it should be executed). You can runwww
directly from the command line. Strictly speaking, it does not say that the contents is JavaScript,.js
extension would imply that more; but it's customary to not have (file format) extensions in executables.
– Sami Hult
Jan 2 at 9:44
Putting .js will tell you how it should be executed too (using node or your browser) and it still can be run directly from the command line. So what a .js extension would imply ?
– S7_0
Jan 5 at 12:38
1
These are all just conventions, nothing more, and some of them are overlapping.node
command does not care about the extension, nor does it care if the file is executable or has hashbang or not - it assumes javascript contents. A browser, on the other hand, is more interested about the mime-type of the file, but can use the extension to determine its type as well. A script will be loaded using e.g.script
tag, and in that case, also the script tag attributes will play role (browsers don't like hashbang lines, they are for command line shells).
– Sami Hult
Jan 5 at 12:58
In short:.js
extension hints you, your editor and your browser what the file type is, but there are plenty of other factors and strategies that are used to determine file type in addition.
– Sami Hult
Jan 5 at 13:00
I don't know if I should create a new post or not but. What is the purpose of putting a hashbang + marked the file as "executable" instead of just creating a .js file ?
– S7_0
Jan 2 at 9:34
I don't know if I should create a new post or not but. What is the purpose of putting a hashbang + marked the file as "executable" instead of just creating a .js file ?
– S7_0
Jan 2 at 9:34
They are just ways of marking the file executable (and telling how it should be executed). You can run
www
directly from the command line. Strictly speaking, it does not say that the contents is JavaScript, .js
extension would imply that more; but it's customary to not have (file format) extensions in executables.– Sami Hult
Jan 2 at 9:44
They are just ways of marking the file executable (and telling how it should be executed). You can run
www
directly from the command line. Strictly speaking, it does not say that the contents is JavaScript, .js
extension would imply that more; but it's customary to not have (file format) extensions in executables.– Sami Hult
Jan 2 at 9:44
Putting .js will tell you how it should be executed too (using node or your browser) and it still can be run directly from the command line. So what a .js extension would imply ?
– S7_0
Jan 5 at 12:38
Putting .js will tell you how it should be executed too (using node or your browser) and it still can be run directly from the command line. So what a .js extension would imply ?
– S7_0
Jan 5 at 12:38
1
1
These are all just conventions, nothing more, and some of them are overlapping.
node
command does not care about the extension, nor does it care if the file is executable or has hashbang or not - it assumes javascript contents. A browser, on the other hand, is more interested about the mime-type of the file, but can use the extension to determine its type as well. A script will be loaded using e.g. script
tag, and in that case, also the script tag attributes will play role (browsers don't like hashbang lines, they are for command line shells).– Sami Hult
Jan 5 at 12:58
These are all just conventions, nothing more, and some of them are overlapping.
node
command does not care about the extension, nor does it care if the file is executable or has hashbang or not - it assumes javascript contents. A browser, on the other hand, is more interested about the mime-type of the file, but can use the extension to determine its type as well. A script will be loaded using e.g. script
tag, and in that case, also the script tag attributes will play role (browsers don't like hashbang lines, they are for command line shells).– Sami Hult
Jan 5 at 12:58
In short:
.js
extension hints you, your editor and your browser what the file type is, but there are plenty of other factors and strategies that are used to determine file type in addition.– Sami Hult
Jan 5 at 13:00
In short:
.js
extension hints you, your editor and your browser what the file type is, but there are plenty of other factors and strategies that are used to determine file type in addition.– Sami Hult
Jan 5 at 13:00
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53988314%2fwhy-bin-www-is-consider-as-a-javascript-file-without-the-js-extention-when-i-u%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown