NodeJS Sublime环境配置

本文介绍如何在Sublime Text中配置Node.js开发环境,包括安装必要的插件、设置构建系统及环境变量等步骤,并提供了一些常用的Sublime插件推荐。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原创转载请注明出处:http://agilestyle.iteye.com/blog/2352335

 

Prerequisite


 


 

 

https://github.com/tanepiper/SublimeText-Nodejs 下载zip包


 

解压后,重命名为nodejs,拷贝到

C:\Users\Administrator\AppData\Roaming\Sublime Text 2\Packages


 

设定build环境为nodejs

Tools > Build System > Nodejs


 

 

配置环境

Preferences > Package Settings > Nodejs > Settings-Default 


修改如下: 

{
  // 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": "C:/Program Files/nodejs/node.exe",
  // Same for NPM command
  "npm_command": "C:/Program Files/nodejs/npm.cmd",
  // as 'NODE_PATH' environment variable for node runtime
  "node_path": "C:/Users/Administrator/AppData/Roaming/npm/node_modules",

  "expert_mode": true,

  "ouput_to_new_tab": false
}

 

新建一个index.js文件,编写一个NodeJS脚本

var http = require('http');

http.createServer(function (request, response) {
	response.writeHead(200, {'Content-Type': 'text/plain'});

	response.end('Hello World\n');
}).listen(8888);

console.log('Server running at http://127.0.0.1:8888/');

 

Ctrl + B运行


 

运行成功后,如果想停止服务,可以在Tools > Cancel Build来停止服务


 

Sublime作为JS IDE安装几个比较著名的插件

JsFormat

https://github.com/jdc0589/JsFormat

Usage

Either cmd+alt+f on OS X or ctrl+alt+f on Linux/Windows

 

JSHint

https://github.com/uipoet/sublime-jshint

Usage

ctrl+j on OS X or alt+j on Linux/Windows

 

JavaScriptNext

https://github.com/Benvie/JavaScriptNext.tmLanguage

Usage

You can either set individual JavaScript files to use this syntax highlighter by changing it in the “View -> Syntax” menu or you can change it for all JavaScript files in the “View -> Syntax -> Open all with current extension as...”.

 

sublime-marko

https://github.com/merwan7/sublime-marko 

 

HTMLPrettify

https://github.com/victorporof/Sublime-HTMLPrettify

 

emmet-sublime

https://github.com/sergeche/emmet-sublime

note:这个插件安装需要安装PyV8(https://github.com/emmetio/pyv8-binaries

emmet初始化html,输入 html:5 ,之后按下 Ctrl + E

 

另外可以修改Sublime默认的 编码、字体大小、Tab

Preferences > Settings - User

{
	"default_encoding": "UTF-8",
	"font_size": 16,
	"tab_size": 2
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值