formidable示例运行报错,解决方法

错误部分:

/home/woofa/Projects/NodeJs/node_modules/formidable/lib/incoming_form.js:28

  this.uploadDir = opts.uploadDir || os.tmpDir();

                                        ^

TypeError: Object #<Object> has no method 'tmpDir'

    at new IncomingForm (/home/woofa/Projects/NodeJs/node_modules/formidable/lib/incoming_form.js:28:41)

    at Server.<anonymous> (/home/woofa/Projects/NodeJs/formidable.js:8:20)

    at Server.emit (events.js:70:17)

    at HTTPParser.onIncoming (http.js:1514:12)

    at HTTPParser.onHeadersComplete (http.js:102:31)

    at Socket.ondata (http.js:1410:22)

    at TCP.onread (net.js:354:27)


解决方法:

(1)$npm install osenv

(2)vim node_modules/formidable/lib/incoming_form.js

       修改第14行:os = require('os'); 改为 os = require('osenv');

       修改第28行:os.tmdDir() 改为 os.tmpdir();


你可能感兴趣的:(formidable示例运行报错,解决方法)