mysql集群节点js连接错误

时间:2014-02-24 13:52:45

标签: node.js mysql-cluster

我正在尝试将mysql集群与节点js连接

我的节目

var nosql = require('mysql-js');

var dbProperties = {

    "implementation" : "ndb",

    "database" : "users"

};

nosql.openSession(dbProperties, null, onSession);

我收到此错误。

https://dev.mysql.com/doc/ndbapi/en/ndb-nodejs-setup.html

Error: Cannot find module 'mysql-js'

at Function.Module._resolveFilename (module.js:338:15) 

at Function.Module._load (module.js:280:25)


if i try to install with npm install mysql-js i am getting below error

npm http GET https://registry.npmjs.org/mysql-js

npm http 404 https://registry.npmjs.org/mysql-js

npm ERR! 404 'mysql-js' is not in the npm registry.

npm ERR! 404 You should bug the author to publish it

npm ERR! 404
npm ERR! 404 Maybe try 'npm search mysql'

npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.

4 个答案:

答案 0 :(得分:0)

您必须下载该模块,并且必须将其放在“node_modules”目录中。

答案 1 :(得分:0)

您需要安装mysql-js。 为此,请转到命令提示符并转到您拥有项目的根目录。

npm install mysql-js

然后运行应用

node app.js //Assuming app.js is the your app file

答案 2 :(得分:0)

你应该像这样安装那个模块:

npm install mysql/mysql-js

npm对Github存储库很聪明)

请注意,它会询问与您的MySQL安装相关的一些问题。

答案 3 :(得分:0)

您需要使用作为MySQL Cluster一部分的node.js驱动程序软件 - 您可以在这篇文章中看到一个有用的教程:
Using JavaScript and Node.js with MySQL Cluster – First steps