【问题标题】:No such file or directory on node shell script节点外壳脚本上没有这样的文件或目录
【发布时间】:2016-03-31 00:03:41
【问题描述】:

我有一个脚本hello,其内容如下:

#!/usr/bin/env node
console.log('hello there!');

当我使用./hello 运行它时,我得到以下输出:

$ ./hello 
: No such file or directory

当我使用node ./hello 运行它时,我得到以下输出:

$ ./hello 
hello there!

这是在 Ubuntu 16.04 上。

【问题讨论】:

  • 我无法复制它。 (刚刚尝试,工作)
  • 你运行 chmod +x hello 了吗?
  • @JamesMonger 你应该已经添加,你正在尝试哪个操作系统。

标签: javascript node.js linux shell ubuntu


【解决方案1】:

通过使用chmod +x hello 设置正确的权限并确保行尾正确,解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-12
    • 2019-09-19
    • 2017-06-16
    • 2016-01-11
    • 2018-08-24
    • 2017-05-14
    • 2020-05-09
    • 2017-08-06
    相关资源
    最近更新 更多