Node.Js - 返回binding.mkdir(pathModule._makeLong(path),

时间:2016-06-21 18:43:04

标签: javascript node.js

我正在尝试运行NodeFuzz。该代码最初是为了在Linux上运行,但我试图在MacOSX上运行它。该文件名为Instrumentation.js 代码来自本文http://jultika.oulu.fi/files/nbnfioulu-201504161396.pdf 这是代码

var spawn=require('child_process').spawn
var fs=require('fs')
var browser={}
function cloneArray(obj){
 var copy = [];
 for (var i = 0; i < obj.length; ++i) {
 copy[i] = obj[i];
 }
 return copy;
}
function saveResults(){
var testCases=cloneArray(config.previousTestCasesBuffer)
var time=new Date().getTime()
if(!fs.existsSync(config.resultDir+'/'+time)){
 fs.mkdirSync(config.resultDir+'/'+time)
 testCases.forEach(function(testCase,index){
 fs.writeFileSync(config.resultDir+'/'+time+'/'+index+'.html',testCase)
 })
 restartBrowser()
}
}
var startBrowser = function(){
browser = spawn(config.browserLaunchCommand, config.browserArguments)
}
function restartBrowser(){
browser.kill()
setTimeout(startBrowser,1000)
}
function handleFeedback(data){
console.log(data)
}
instrumentationEvents.on('websocketTimeout',saveResults)
instrumentationEvents.on('startClient',startBrowser)
instrumentationEvents.on('testCasesWithoutRestartLimit',restartBrowser)
instrumentationEvents.on('feedbackMessage',handleFeedback)

这是错误

Loading default configuration-file:
./config.js
config.js had no property init.
Loading default instrumentation-module:
./Instrumentation.js
No module folder given. Defaulting to ./TestCaseGenerator.js from config.js
Found property init() from module ./TestCaseGenerator.js
Successfully required module ./TestCaseGenerator.js
We have 1 modules available.
Server listening port 1000
Tue Jun 21 2016 12:34:33 GMT-0400 (EDT): Feedback-loop initialized.
fs.js:794
  return binding.mkdir(pathModule._makeLong(path),
             ^

Error: ENOENT: no such file or directory, mkdir './results//1466526873714'
at Error (native)
at Object.fs.mkdirSync (fs.js:794:18)
at EventEmitter.saveResults (/Users/greg/NodeFuzz/Instrumentation.js:15:5)
at emitNone (events.js:67:13)
at EventEmitter.emit (events.js:166:7)
at null._onTimeout (/Users/student/NodeFuzz/nodefuzz.js:216:30)
at Timer.listOnTimeout (timers.js:92:15)

1 个答案:

答案 0 :(得分:0)

替换通过连接创建路径的所有内容

例如config.resultDir+'/'+time+'/'+index+'.html'

使用:

var path = require('path'); //at the top of the file
path.join(config.resultDir, time, index + '.html')

现在你将保证在你的路径中永远不会有双/,并且作为奖励,它将为你的操作系统使用正确的路径分隔符(如果你也想在Windows上运行它)