What does the command "node ." do?

13,512

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.

Share:
13,512
Rogen George
Author by

Rogen George

Software Engineer at Infosys.

Updated on June 12, 2022

Comments

  • Rogen George
    Rogen George almost 2 years

    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.*"
      }
    }