demo_events_open.js:
var fs = require('fs'); var readStream = fs.createReadStream('./demofile.txt'); /*Write to the console when the file is opened:*/ readStream.on('open', function () { console.log('The file is open'); });
C:\Users\My Name>node demo_events_open.js
The file is open