一.初始环境搭建

mkdir server //创建server文件夹
cd server //进入到创建的文件夹目录下
npm init -y //生成含有默认配置的package.json文件
npm install @types/node --save //配置node的类型定义文件
npm install express --save //安装express
npm install @types/express --save //安装express的类型定义文件server目录下新建tsconfig文件
npm install -g typescript //配置typescript开发环境,没有安装typescript需要全局安装

sumblime Text3下,配置Tools/Build System/New Build System里写入文件

{
"cmd": ["tsc","$file"],
"file_regex": "(.*\\.ts?)\\s\\(([0–9]+)\\,([0–9]+)\\)\\:\\s(...*?)$",
"selector": "source.ts",
"osx": {
"path": "/usr/local/bin:/opt/local/bin"
},
"windows": {
"cmd": ["tsc", "$file"]
}
}

保存为TypeScript.sublime-build, Build System设置为Automatic, ctrl+B编译ts文件,会自动生成对应的js文件

二.入门小例
1. 初始化server服务,建立hello_server.ts文件
2. 命令行输入 `tsc server/hello_server.ts`,生成对应的hello_server.js文件
3. 命令行启动8000端口,node server/hello_server.js,打开`localhost:8000`,可以看到`hell node!`

项目地址 https://github.com/leitingting08/server

node.js创建server服务---sublime 的node及typescript环境配置的更多相关文章

  1. node.js创建简单服务测试请求数据

    工具:安装node: 1,创建文件夹 server, 2 ,在server文件夹下分别创建server.js 和 package.json 文件 3,server.js 代码: var express ...

  2. node.js 创建 wss服务

    var https=require('https'); var ws=require('ws'); var fs=require('fs'); var keypath=process.cwd()+'/ ...

  3. Node.js 创建server服务器

    var http=require('http'); //引入http模块 var server=http.createServer(function(req,res){  //创建一个server r ...

  4. Node.js创建服务器和模拟客户端请求

    1. 何为服务器 服务器是某种长期运行,等待请求资源的应用程序 2. 常见Web应用架构 3. 如何创建web服务器 Web服务器是使用HTTP协议,等待客户端连接后请求资源的驻守应用程序:HTTP协 ...

  5. 使用 Node.js 搭建微服务网关

    目录 Node.js 是什么 安装 node.js Node.js 入门 Node.js 应用场景 npm 镜像 使用 Node.js 搭建微服务网关 什么是微服务架构 使用 Node.js 实现反向 ...

  6. Node.js 创建HTTP服务器

    Node.js 创建HTTP服务器 如果我们使用PHP来编写后端的代码时,需要Apache 或者 Nginx 的HTTP 服务器,并配上 mod_php5 模块和php-cgi. 从这个角度看,整个& ...

  7. Node.js 创建HTTP服务器(经过测试,这篇文章是靠谱的T_T)

    Node.js 创建HTTP服务器 如果我们使用PHP来编写后端的代码时,需要Apache 或者 Nginx 的HTTP 服务器,并配上 mod_php5 模块和php-cgi. 从这个角度看,整个& ...

  8. node.js在windows下的学习笔记(5)---用NODE.JS创建服务器和客户端

    //引入http模块 var http = require('http'); //调用http的createServer的方法,这个方法有一个回调函数,这个回调数 //的作用是当有请求发送给服务器的时 ...

  9. [转]用Node.js创建自签名的HTTPS服务器

    用Node.js创建自签名的HTTPS服务器 创建自己的CA机构 创建服务器端证书 创建客户端证书 将证书打包 创建自己的CA机构 为CA生成私钥 openssl genrsa -out ca-key ...

随机推荐

  1. 将相关数据拼成所需JSON数据

    参考: http://www.cnblogs.com/shuilangyizu/p/6019561.html 有时候我们需要将一些数据拼装成所需要格式的JSON,可以使用如下方法,本人觉得还是比较方便 ...

  2. MySQL replace into 用法

    讨人喜欢的 MySQL replace into 用法(insert into 的增强版) 在向表中插入数据的时候,经常遇到这样的情况:1. 首先判断数据是否存在: 2. 如果不存在,则插入:3.如果 ...

  3. sqlzoo练习答案--SUM and COUNT

    World Country Profile: Aggregate functions This tutorial is about aggregate functions such as COUNT, ...

  4. android BaseAdapter getView 理解

    ListView是安卓中很经常使用的一个控件. 安卓设计使用Adapter来对ListView进行管理. 可是系统提供的Adapter无法满足一些复杂的显示情况,这个时候我们就须要使用BaseAdap ...

  5. angular关于表单指令的汇总

  6. 每日英语:China's Bad Earth

    In Dapu, a rain-drenched rural outpost in the heart of China's grain basket, a farmer grows crops th ...

  7. Debian8.0 搭建leanote

    参考了官方wiki以及中文博客 https://github.com/leanote/leanote/wiki http://leanote.leanote.com/post/Leanote-manu ...

  8. C语言 · 复数归一化

     算法提高 复数归一化   时间限制:1.0s   内存限制:512.0MB      编写函数Normalize,将复数归一化,即若复数为a+bi,归一化结果为a/sqrt(a*a+b*b) + i ...

  9. PHP——0128练习相关1——window.open()

    Window.open()方法参数详解 1, 最基本的弹出窗口代码   window.open('page.html'); 2, 经过设置后的弹出窗口   window.open('page.html ...

  10. C++中变量做数组长度

    在Java中,这是完全可以的,比如我们运行如下程序: package cn.darrenchan.storm; import java.util.Arrays; public class Test { ...