赞
踩
https://nodejs.org/en/download/
双击安装程序,开始安装,安装完成后,在控制台输入 :```node -v```
打印出版本号说明安装成功。
配置环境变量:我的电脑-->属性-->高级设置-->环境变量:
把 D:\Program Files\nodejs 配置到 Path环境变量。
http://www.sublimetext.com/
https://github.com/tanepiper/SublimeText-Nodejs
1、解压后,重命名为:Nodejs
2、把Nodejs复制到sublime Text 的 packages目录下
3、重启sublime Text
4、打开sublime Text --> Tools --> Bulid System --> nodejs
打开 Nodejs.sublime-settings, node_command 和 npm_command 分别配置成安装node的exe文件的绝对路径
// 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": "D:\\Program Files\\nodejs\\node.exe",
// Same for NPM command
"npm_command": "D:\\Program Files\\nodejs\\npm.cmd",
// as 'NODE_PATH' environment variable for node runtime
"node_path": false,
"expert_mode": false,
"output_to_new_tab": false
}
打开Nodejs.sublime-build 修改编码:
"cmd": ["node", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.js", "shell": true, "encoding": "GB2312", "windows": { "shell_cmd": "taskkill /F /IM node.exe & node $file" }, "linux": { "shell_cmd": "killall node; /usr/bin/env node $file" }, "osx": { "shell_cmd": "killall node; /usr/bin/env node $file" } }
新建Hello World.js
var http = require('http');
var os = require('os');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(3000);
console.log('Server running at http://127.0.0.1:3000/');
编译 crtl + B
控制台输出:
浏览器输入:http://127.0.0.1:3000/
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。