Alan
Alan

Reputation: 2086

Node Error on installing custom script

I have some code that a programmer made for our company using Node 0.10 that I am trying to update to node 6.9 in a dev environment. I am not a Node guru, this is a project helping me to learn Node and the code left for us.

When I run the reccomended install script, I get this error:

# node install.js --production
path.js:7
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.dirname (path.js:1324:5)
    at new daemon (/var/www/ClientResponder/node_modules/node-linux/lib/daemon.js:208:30)
    at Object.<anonymous> (/var/www/ClientResponder/install/install.js:13:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)

I look at the file install.js, line 11 starts off like this:

/**
 * Created by Tim.
 */

var Service = require('node-linux').Service;

var env = null;
if(process.argv.length === 3){
    env = process.argv[2] === "--production" ? "production" : "staging";
}

// Create a new service object
var svc = new Service({
    name:'Client Responder',
    description: "Optional web server which can be deployed to a Media Server providing user clients the ability to ping the server for speed tests.",
    script: '/var/www/ClientResponder/server.js',
    env: [{
        name: "NODE_ENV",
        value: env ? env : "staging"
    },{
        name: "PORT",
        value: 8888
    }]
});

// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
    svc.start();
});

svc.install();

I didn't see anything there about the path, so I look at the daemon.js file at line 208 and get this:

cwd: {      
  enumerable: false,          
  writable: true,          
  configurable: false,          
  value: config.cwd || p.dirname(this.script)
},      

What am I missing here? I realize it is hard to know when you don't have full access to all source code, what more can I provide that would help short of full access?

Upvotes: 0

Views: 54

Answers (1)

joaumg
joaumg

Reputation: 1248

The suggested workaround here is to follow this issue.

And change:

var svc = new Service({
    name:'Client Responder',
    description: "Optional web server which can be deployed to a Media Server providing user clients the ability to ping the server for speed tests.",
    script: '/var/www/ClientResponder/server.js',
    env: [{
        name: "NODE_ENV",
        value: env ? env : "staging"
    },{
        name: "PORT",
        value: 8888
    }]
});

To:

var svc = new Service({
    name:'Client Responder',
    description: "Optional web server which can be deployed to a Media Server providing user clients the ability to ping the server for speed tests.",
    script: 'server.js', // here
    cwd: '/var/www/ClientResponder/', // and here
    env: [{
        name: "NODE_ENV",
        value: env ? env : "staging"
    },{
        name: "PORT",
        value: 8888
    }]
});

Upvotes: 1

Related Questions