我有一些程序员使用Node 0.10为我们公司制作的代码,我试图在开发环境中更新到节点6.9。我不是Node guru,这是一个项目,帮助我学习Node和为我们留下的代码。
当我运行推荐的安装脚本时,我收到此错误:
# 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)
我看一下install.js文件,第11行就像这样开始:
/**
* 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();
我没有看到关于路径的任何内容,所以我在第208行查看daemon.js文件并获取此信息:
cwd: {
enumerable: false,
writable: true,
configurable: false,
value: config.cwd || p.dirname(this.script)
},
我在这里缺少什么?我意识到很难知道什么时候您无法完全访问所有源代码,我还能提供什么更有助于完全访问?
答案 0 :(得分:1)
此处建议的解决方法是遵循this issue。
并改变:
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
}]
});
要:
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
}]
});