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

时间:2018-11-26 14:15:35

标签: javascript sublimetext3

这是我的代码:

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]

1 个答案:

答案 0 :(得分:0)

首先请确保您已安装pythonnode

打开sublime text> Tools> Build System> New Build System>复制并粘贴Python Build System代码,用您的python位置更改“ cmd”路径>按{ {1}}用所需的任何文件名将生成文件保存在默认位置,但请确保文件扩展名为ctrl+s

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

Python构建系统代码

.sublime-build

JavaScript构建系统代码

{
    "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"
}

创建两个构建系统后,现在再次打开{ "cmd": ["/usr/path/to/your/node", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "quiet": true, "selector": "source.js" } > sublime text> Tools> Build System

打开您的Automaticjavascript文件,按python选择您的构建系统,您就可以摇滚了!