我 fork 了 bookmarking project 并按照安装和设置文档进行操作,直到达到
Edit the configuration section of server.js to point to your database
该部分看起来像
/* ==============================================================
Configuration
=============================================================== */
//used for session and password hashes
var salt = '20sdkfjk23';
var client = new Client();
client.host = 'hostname';
client.user = 'username';
client.password = 'password';
client.database = 'bookmarks';
var app = express.createServer();
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({ secret: salt, store: new RedisStore, cookie: { maxAge: 3600000 * 24 * 30 } }));
app.use(express.methodOverride());
app.use(express.logger({ format: ':method :url' }));
delete express.bodyParser.parse['multipart/form-data'];
app.use('/css', express.static(__dirname + '/public/css'));
app.use('/js', express.static(__dirname + '/public/js'));
app.use('/images', express.static(__dirname + '/public/images'))
app.use(express.favicon(__dirname + '/public/favicon.ico'));
我已将 __dirname 的实例更改为正确的目录,并且我在 google 上搜索了如何获取计算机的主机名。我已经换了它并尝试在我的计算机上使用我的用户名,但我很尴尬地承认我不确定这就是我应该在这里做的事情。同样,我尝试使用 mysql 数据库的密码作为 client.password 值。
无论我在该部分中输入什么内容,我都会收到此消息。
/Users/Spladow/repos/Bookmarkly/node_modules/connect-redis/node_modules/redis/index.js:1246
throw new Error('unknown type of connection in createClient()');
^
Error: unknown type of connection in createClient()
at new exports.createClient (/Users/Spladow/repos/Bookmarkly/node_modules/connect-redis/node_modules/redis/index.js:1246:15)
at new RedisStore (/Users/Spladow/repos/Bookmarkly/node_modules/connect-redis/lib/connect-redis.js:51:37)
at Object.<anonymous> (/Users/Spladow/repos/Bookmarkly/server.js:32:48)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:929:3
我真的不知道我应该改变什么,并且希望得到建议。谢谢。
最佳答案
是啊,我也遇到了同样的问题~ 因为我想要一个很好的backbone演示来练习然后我发现了Bookmarly 。 最后通过google才知道这个问题~
这是我的解决方案:
- 启动redis服务器。
redis 服务器
- 更改
server.js
代码。
改变
app.use(express.session({ secret: salt, store: new RedisStore(), cookie: { maxAge: 3600000 * 24 * 30 } }));
至
app.use(express.session({ secret: salt, store: new RedisStore({host:'127.0.0.1', port:6379}), cookie: { maxAge: 3600000 * 24 * 30 } }));
当然mysql必须工作。 给大家截图一下~
关于mysql - 配置服务器在本地运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27588047/