Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node and shebang : help executing via command line

My node installation is at:

/usr/local/bin/node

and I've added the shebang:

#!/usr/local/bin/node

to the top of the file and given my node app file the permissions 755, but when I try to run:

> ./my-app

I get the old:

-bash: ./my-app: No such file or directory

What am I doing wrong?

like image 616
asking Avatar asked Jun 16 '14 22:06

asking


People also ask

CAN node Run command line?

Node. js can run shell commands by using the standard child_process module. If we use the exec() function, our command will run and its output will be available to us in a callback. If we use the spawn() module, its output will be available via event listeners.

What is the command to run the node program?

Type node followed by the name of the application, which is test-node. js in this case, and then press Enter . The result of running the application will be printed out to the command prompt.

What is a shebang in node?

Shebang or hashbang ( #! ) is the first line of the file which tells the OS which interpreter to use. It typically looks like this: #!/absolute/path/to/the/interpreter [optional params]

What is the correct command to start node js on command line?

js/JavaScript code. To launch the REPL (Node shell), open command prompt (in Windows) or terminal (in Mac or UNIX/Linux) and type node as shown below. It will change the prompt to > in Windows and MAC. You can now test pretty much any Node.


1 Answers

The node shebang is:

#!/usr/bin/env node 

Not all systems place node in the same location, its possible that you have the location incorrectly. This will find them all.

Source

Also

like image 153
secretformula Avatar answered Nov 10 '22 00:11

secretformula