标签:
就练练手,
嘿嘿,说不定,写服务器脚本也可以哟。
console.log(‘Currently executing file is ‘ + __filename); console.log(‘It is located in ‘ + __dirname); console.log(‘Starting in ‘ + process.cwd()); try { process.chdir(‘/‘); } catch (error) { console.error(‘chdir: ‘ + error.message); } console.log(‘Current working directory is now ‘ + process.cwd()); var fs = require(‘fs‘); fs.readFile(__filename, function(error, data) { if (error) { return console.error(error.message); } console.log(data); }); fs.readFile(__filename, { encoding: ‘utf8‘ },function(error, data) { if (error) { return console.error(error.message); } console.log(data); }); var data; try { data = fs.readFileSync(__filename); console.log(data); } catch(error) { console.error(error.message); }
标签:
原文地址:http://www.cnblogs.com/aguncn/p/5131706.html