node.js node 和 shebang:帮助通过命令行执行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24253027/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 17:29:11  来源:igfitidea点击:

node and shebang : help executing via command line

node.jspathshebang

提问by asking

My node installation is at:

我的节点安装在:

/usr/local/bin/node

/usr/local/bin/node

and I've added the shebang:

我添加了shebang:

#!/usr/local/bin/node

#!/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:

到文件顶部,并为我的节点应用程序文件授予权限 755,但是当我尝试运行时:

> ./my-app

> ./my-app

I get the old:

我得到旧的:

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

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

What am I doing wrong?

我究竟做错了什么?

回答by secretformula

The node shebang is:

节点shebang是:

#!/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