Sublime Text Ctrl + B 不会显示输出 (JavaScript)

Sublime Text Ctrl + B wont show output (JavaScript)

这是我的代码:

var message = "Hello World";
console.log(message);

下面是Ctrl+B后的错误:

/home/kazak/.config/sublime-text-3/Packages/User/javaScr.js: line 1: var: command not found
/home/kazak/.config/sublime-text-3/Packages/User/javaScr.js: line 2: syntax error near unexpected token `message'
/home/kazak/.config/sublime-text-3/Packages/User/javaScr.js: line 2: `console.log(message);'
[Finished in 0.0s with exit code 2]
[cmd: ['/bin/bash', '/home/kazak/.config/sublime-text-3/Packages/User/javaScr.js']]
[dir: /home/kazak/.config/sublime-text-3/Packages/User]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]

首先确保你已经安装了pythonnode

打开 sublime text > Tools > Build System > New Build System > 复制并粘贴 Python Build System 代码,将 "cmd" 路径更改为 python location > press ctrl+s 将构建文件保存在默认位置,使用您想要的任何文件名,但确保文件扩展名为 .sublime-build

对 javascript 构建系统执行相同的操作并将 "cmd" 路径更改为您的节点位置。

Python 构建系统代码

{
    "cmd": ["/usr/path/to/your/python", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    // if you want to see the execution information set "quiet":false
    "quiet": true,
    "selector": "source.python"
}

JavaScript 构建系统代码

{   
    "cmd": ["/usr/path/to/your/node", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "quiet": true,
    "selector": "source.js"
}

创建两个构建系统后,现在再次打开 sublime text > Tools > Build System > Automatic

打开你的 javascriptpython 文件按 ctrl+b select 你的构建系统,你准备好了!