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?
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.
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.
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]
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With