Skip to content

DeprecationWarning: Calling an asynchronous function without callback is deprecated. in fs.writeFile #14770

Description

@thidasapankaja

Version: v8.0.0
Platform: Linux pankaja-HP-Pavilion-15-Notebook-PC 4.10.0-30-generic #34~16.04.1-Ubuntu SMP Wed Aug 2 02:13:56 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Subsystem: fs.writeFile

Error : (node:10801) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.

Code :

var http = require('http');
var fs = require('fs');

var server = http.createServer(function(req, res){

	fs.readFile("text.txt",'utf-8',function(error, data){
		res.writeHead(200,{
			'Content-Type': 'tex/plain'
		});

		data = parseInt(data) + 1;

		fs.writeFile("text.txt", data);

		res.end('This page was refreshed ' + data + ' times!');
	})
});

server.listen(8080, function(){
	console.log('your server is running at 127.0.0.1:8080')
})

I was following this tutorial and when Reading and Writing files I'm getting this error. When I use node --trace-deprecation file.js I'm getting this log message.

(node:10880) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
at maybeCallback (fs.js:119:42)
at Object.fs.writeFile (fs.js:1256:14)
at /media/pankaja/Local Disk/Projects/Nodejs/Tutorial/file.js:14:6
at tryToString (fs.js:499:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:487:12)

Is this a bug ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to file-system APIs and the fs module.questionIssues asking questions about Node.js.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions