Reno
Reno

Reputation: 1139

Difference between "./ [filename]" vs. "node [filename]"

could someone help me understand the difference between running a node script from terminal using ./ [Filename] versus running it with node [filename] ?

Thank you very much.

Upvotes: 0

Views: 80

Answers (1)

Leonid Beschastny
Leonid Beschastny

Reputation: 51480

It's the same as running bash script using ./[Filename] or bash [Filename].

To use ./[Filename] syntax your node script should:

  • be runable (chmod +x [Filename])
  • contain proper header (e.g. #!/usr/bin/node or #!/usr/bin/env node)

There is no requirements for running your script with node [Filename].

Upvotes: 2

Related Questions