搭建Node.js Redis开发环境
创建项目
初始化为node项目
$npm init
安装redis
安装@types/node, @types/redis, typescript
初始化TypeScript
配置tsconfig.json
参考package.json
{
"name": "redis-demo",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"build": "tsc",
"dev": "tsc -w",
"start": "node .\\build\\app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^9.6.0",
"@types/redis": "^2.8.6",
"typescript": "^2.7.2"
},
"dependencies": {
"redis": "^2.8.0"
}
}
新建文件App.ts
import
*
as redis from
"redis"
console.log("redis node.js demo!");
let client = redis.createClient();
client.on("error", function (err) {
console.log("Error " + err);
});
client.set("hello", "redis", redis.print);
client.get("hello", (err, reply) => {
console.log("Error %s ", err);
console.log("Reply %s ", reply);
});
编译App
$ npm run dev
运行App
$ npm start
参考资源:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/redis/redis-tests.ts
https://npm.taobao.org/package/redis
最新文章
- json文件
- 百度文库下载器 V2.3.4.3 支持豆丁百度文库道客巴巴
- web应用程序测试方法和测试技术详述
- 转:GROUPING SETS、ROLLUP、CUBE
- ADF_Database Develop系列1_设计数据库表之Diagram/Tables/View/Sequence
- WIN8+VS2013编写发布WCF之三(调用)
- WPF——绑定数据库数据(Listview)
- boost总结之variant
- 【JQuery学习历程】1.初识JQuery
- 【IE6的疯狂之十二】一个display:none引起的3像素的BUG
- 安装Sphere v2.7 遇到的问题
- [Swift]LeetCode93. 复原IP地址 | Restore IP Addresses
- 雷林鹏分享:CodeIgniter 数据库操作
- Kafka(2)--kafka基本原理之消息的分发与接收
- (二 -5) 天猫精灵接入Home Assistant-自动发现Mqtt设备--电风扇
- p86商空间也是Banach空间
- namecheap域名设置Cloudflare为第三方DNS
- JavaScript 对象拷贝研究
- python全栈开发day48-jqurey自定义动画,jQuery属性操作,jQuery的文档操作,jQuery中的ajax
- MAC下调试JSON接口的工具(HTTP抓包工具)
热门文章
- javascript之系统对话框
- 【总结整理】JQuery基础学习---动画
- 5、预测和鉴定miRNA的靶基因
- 使用CocoaLumberjack时,自定义的log文件名
- 20.Ecshop 2.x/3.x SQL注入/任意代码执行漏洞
- 1.jQuery入口函数 与javaScript入口函数
- kingadmin
- 浅谈JavaScript--事件委托与事件监听
- 【转】C# 使用正则表达式去掉字符串中的数字,或者去掉字符串中的非数字
- 洛谷P1607 [USACO09FEB]庙会班车Fair Shuttle