0

node module not found

i'm getting the following error in the log:

[ 35.300] [INFO] [source file:///index.html:24]: Server responded to request from ::ffff:10.10.10.102
[ 35.301] [ERROR] [source module.js:340]: Uncaught Error: Cannot find module '/storage/sd/mysql'

 

i'm trying to access an sql database with nodejs:

mysql = require(storagePrefix + '/mysql');
connection = mysql.createConnection(
{
host:"10.10.10.102",
port:3306,
user:"root",
password:"password1",
database:"playlistdb"
});

 

 

1 comment

  • 0
    Avatar
    Lyndon

     

    You need to define a path in the node server file. With Brightsign players you need to define a ‘use’ path(s) with  ‘path’. See example below. 

     

    var process = require('process');

    console.log(process.cwd());

    process.chdir("/storage/sd");

    console.log(process.cwd());

    var express = require('express');

    var app = express();

    var path = require('path');

    var bodyParser = require('body-parser');

    var router = express.Router();

     

    // viewed at http://localhost:8000

    app.get('/', function(req, res) {

        res.sendFile('/storage/sd/node/index.html');

    });

     

    app.use("/pics", express.static('/storage/sd/node/pics'));

    app.use("/css", express.static( '/storage/sd/node/css'));

    app.use("/js", express.static( '/storage/sd/node/js'));

    app.use("/node_modules", express.static( '/storage/sd/node/node_modules'));

Please sign in to leave a comment.