Tag: typeerror

Formidable和Node.js TypeError:无法读取未定义的属性“path”

如果你正在阅读这篇文章,你可能会遵循Manuel Kiessling的Node教程。 在完成教程的file upload部分时,我收到以下错误。 fs.rename(files.upload.path, "img/img.jpg", function(error) { ^ TypeError: Cannot read property 'path' of undefined 我search了一下,发现了这个 ,但是他们相当不确定,没有提供什么帮助。

Node Beginner Book TypeError:不能调用未定义的方法'writeHead'

我只是按照http://www.nodebeginner.org/上的Node Beginner Book ,而遇到TypeError ,我search了但没有人能解决这个错误。 错误显示如下 D:\delbert\nodejs\proj\requestHandlers.js:7 response.writeHead(200, {"Content-Type":"text/plain"}); ^ TypeError: Cannot call method 'writeHead' of undefined at D:\delbert\nodejs\proj\requestHandlers.js:7:14 at ChildProcess.exithandler (child_process.js:635:7) at ChildProcess.EventEmitter.emit (events.js:98:17) at maybeClose (child_process.js:743:16) at Socket.<anonymous> (child_process.js:956:11) at Socket.EventEmitter.emit (events.js:95:17) at Pipe.close (net.js:465:12) 和源代码: // ——— // //server.js// // ——— // var http = require("http"); var url = require("url"); function start(route, […]

JavaScript和分号

'use strict' [1,2,3,4].find(x => x > 1) 当使用nodejs 5.0.0执行上述代码时,会出现以下错误: TypeError: "use strict"[(((1 , 2) , 3) , 4)].find is not a function at Object.<anonymous> (C:\src\nodejs\ecma6.js:2:11) at Module._compile (module.js:425:26) at Object.Module._extensions..js (module.js:432:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Function.Module.runMain (module.js:457:10) at startup (node.js:136:18) at node.js:972:3 如果在“严格使用”之后添加分号,则错误消失。 这看起来像一个bug …还是有什么更深层次的 – 意味着在语言规范中是否有一个例外情况的列表,其中需要分号。 更新 语言规范确实列出了需要明确分号的例外情况。

'TypeError:undefined不是'跳转补间模块时的函数'

我不断收到这个问题,我的应用程序崩溃,每当我从另一个调用函数的节点。 我已经做了这个最小的工作示例(工作在它给我的错误): 启动模块 var module2 = require('./module2'); var data = 'data'; module2.doStuff(data); 单词数 var module3 = require('./module3'); function doStuff(data){ // Stuff happens to 'data' module3.takeStuff(data); } function doSomethingElse(data){ console.log(data); } module.exports = { doStuff: doStuff, doSomethingElse: doSomethingElse }; 单词数 var module2 = require('./module2'); function takeStuff(data){ // Stuff happens to 'data' module2.doSomethingElse(data); // I get the […]

TypeError:Undefined不是一个函数 – Sails.js

所以我现在通过一些教程学习了Sails.js ,现在我已经多次遇到这个问题。 我试图寻找解决scheme,但没有一个似乎工作。 module.exports = { signup: function(req, res) { var username = req.param("username"); var password = req.param("password"); Users.findByUsername(username).done(function(err, usr){ if (err) { res.send(500, { error: "DB Error" }); } else if (usr) { res.send(400, {error: "Username already Taken"}); } else { var hasher = require("password-hash"); password = hasher.generate(password); Users.create({username: username, password: password}).done(function(error, user) { […]