使用node supervisor启动项目时遇到的坑
代码如下
//上传完成后处理
form.parse(req, function (err, fields, files) {
var filesTmp = JSON.stringify(files, null, 2);
if (err) {
console.log('parse error: ' + err);
} else {
// console.log('parse files: ' + filesTmp);
var inputFile = files.upfile[0];
var uploadedPath = inputFile.path;
var dstPath = 'public/uploadDir/' + inputFile.originalFilename;
//重命名为真实文件名
fs.rename(uploadedPath, dstPath, function (err) {
if (err) {
console.log('rename error: ' + err);
} else {
console.log('rename ok');
var obj = xlsx.parse(dstPath);
console.log(JSON.stringify(obj));
}
});
success(files);
}
});
下面是用supervisor启动项目时运行代码的log
POST /importStu 200 23.844 ms - 325
rename ok
crashing child
Starting child process with 'node bin\www'
js-bson: Failed to load c++ bson extension, using pure JS version
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
Server is running on localhost:3000/
Fri, 26 Feb 2016 09:27:42 GMT e-exam:server Listening on port 3000
下面是用node启动项目时运行代码的log
POST /importStu 200 21.133 ms - 325
rename ok
[{"name":"Sheet1","data":[["姓名","学号","身份证号","角色","专业"],["a",120522111,11111111111,2,"网络工程"],["b",120522130,11111,2,"网络工程"],["c",120522132,2222222,2,"网络工程"]]}]
有人遇到过类似的情况吗?,为什么用supervisor在那个地方会crash掉。