Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
186
rated 0 times [  187] [ 1]  / answers: 1 / hits: 18137  / 8 Years ago, wed, may 11, 2016, 12:00:00

The README document of my node server instructs me to run this command on my command prompt.



node .


What does this command do? How does it start my node server?



My package.json contents are



{
name: uber-api,
version: 1.0.0,
description: Move your app forward with the Uber API,
main: index.js,
keywords: [
swagger
],
license: MIT,
private: true,
dependencies: {
connect: ^3.2.0,
js-yaml: ^3.3.0,
swagger-tools: 0.9.*
}
}

More From » node.js

 Answers
77

By default Node.js is trying to load a module located in the folder that you are passing to it as an argument (. - just bash variant of the current folder). Then it runs whatever is written in the "main" section of the package.json file found in this folder.


In your case, it'll try to run node ./index.js


Doc: https://docs.npmjs.com/files/package.json#main


Good point from @djechlin: if no package.json found in the folder or if no "main" section is present, then Node.js will try to run the index.js file in this particular folder you are passing.


[#62226] Monday, May 9, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
danar

Total Points: 271
Total Questions: 94
Total Answers: 93

Location: Ecuador
Member since Thu, Jun 4, 2020
4 Years ago
;