惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 抱影无眠

CentOS7安装Nginx实现API网关 CentOS7中添加新硬盘 CentOS7 安装oracle 客户端 CentOS7安装RabbitMQ CentOS7安装MongoDB3.6企业版 CentOS 搭建Redis4 环境 Nginx 在Windows下搭建静态Web服务 DevExtreme 搭建Node.js开发环境 MongoDB 搭建Node.js开发环境 MongoDB Windows环境搭建 Oracle 搭建Node.js开发环境 Redis Windows环境搭建 使用PM2守护Node.js应用 Windows下使用nvm管理多个Node.js 版本 vscode 插件todo-highlight Ionic 解决gradle下载慢的问题 Cmder 简明使用说明 Ionic2 开发环境搭建 Ionic2集成DevExtreme
搭建Node.js Redis开发环境
抱影无眠 · 2018-03-25 · via 博客园 - 抱影无眠

创建项目

初始化为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