Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9085977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:22:34+00:00 2026-06-16T21:22:34+00:00

I have one node.js application published in appfog, but when I try to access

  • 0

I have one node.js application published in appfog, but when I try to access a mysql database through javascript
with ( https://github.com/felixge/node-mysql ), “node-mysql” seems that is not installed, what is the way to do this?
there is no documentation on appfog site. thanks.

the code of server app.js:

if(process.env.VCAP_SERVICES){
var env = JSON.parse(process.env.VCAP_SERVICES);
var cre = env['mysql-5.1'][0]['credentials'];
}
var Client = require('mysql').Client,
client = new Client();
client.user = cre.user;
client.password = cre.password;
client.host=cre.host;
client.port=cre.port;
client.database=cre.name;
client.connect();

client.query(
    'SELECT * FROM scores ',
    function selectPlayers(err, results, fields) {
        if (err) {
            console.log("Error: " + err.message);
            throw err;
        }
        console.log("Number of rows: "+results.length);
        console.log(results);
        client.end();
    });

and the error:

module.js:340
throw err;
      ^
Error: Cannot find module 'mysql'
at Function.Module._resolveFilename (module.js:338:15)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:22:35+00:00Added an answer on June 16, 2026 at 9:22 pm

    you should add

    "mysql": "2.0.x || 2.1.x",
    

    to the dependencies in your package.json file, and then do

    npm install
    

    You can check out Appfog’s documentation here. There is a section about dependency management

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a memory leak on one of the part of my node.js application.
I need to set GCGraceSeconds to 0, because I have only one node, but
I have one repo hosted at https://github.com/aikiframework/json . On my local copy, I added
I have a Node.js application that saves data to MongoDB. Given one document, I
I want to write one web application with node.js and MongoDB and I have
I have several javascript files that contain different parts of my node application. They
I have multiple daemons (one gateway and multiple service, all running on same node)
I have a several processes node.js. I want to only add one string to
I have a 3 node Cassandra cluster with replication factor of 2. Because one
I have a WPF application that has just one button. When the button is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.