sublime3安装javascript控制台环境 方法2

时间:2023-03-10 04:50:04
sublime3安装javascript控制台环境 方法2

1.下载node.js

sublimeText3- 安装nodejs插件   ctrl+shift+p — install package —nodejs

2.修改配置文件

在 Sublie Text 3 Packages 文件目录下, 找到 Nodejs.sublime-settings 文件,更改以下内容

{
// save before running commands
"save_first": true,
// if present, use this command instead of plain "node"
// e.g. "/usr/bin/node" or "C:\bin\node.exe"
"node_command": "E:\\Program Files\\nodejs\\node.exe", //node.js安装路径
// Same for NPM command
"npm_command": "E:\\Program Files\\nodejs\\npm.cmd", //node.js安装路径
// as 'NODE_PATH' environment variable for node runtime "node_path": false, "expert_mode": false, "ouput_to_new_tab": false }

在 Sublie Text 3 Packages 文件目录下, 找到 Nodejs.sublime-build 文件,更改以下内容

{
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell": true,
"encoding": "utf8", //此处修改
"windows":
{
"cmd": ["node", "$file"] //此处修改
//"cmd": ["node", "--use-strict", "--harmony", "$file"] //与上面二选一 兼容ES6语法
},
"linux":
{
"shell_cmd": "killall node; /usr/bin/env node $file"
},
"osx":
{
"shell_cmd": "killall node; /usr/bin/env node $file"
}
}

重启,运行。