fs writefile node
// writefile.js
const fs = require('fs');
let lyrics = 'But still I\'m having memories of high speeds when the cops crashed\n' +
'As I laugh, pushin the gas while my Glocks blast\n' +
'We was young and we was dumb but we had heart';
// write to a new file named 2pac.txt
fs.writeFile('2pac.txt', lyrics, (err) => {
// throws an error, you could also catch it here
if (err) throw err;
// success case, the file was saved
console.log('Lyric saved!');
});
const fs = require('fs')
const content = 'Some content!'
fs.writeFile('/Users/joe/test.txt', content, err => {
if (err) {
console.error(err)
return
}
//file written successfully
})fs.writeFile('2pac.txt', 'Some other lyric', 'ascii', callback);
Also in JavaScript:
- angular router navigate
- javascript reverse array
- express.js server
- missing json after pyinstaller
- Exception in thread "main" org.openqa.selenium.JavascriptException:
- adding a variable to a string without using + in javascript
- angular add bootstrap
- angular 9 dockerfile
- how to make text come up with javascript
- angular ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked.
- js object sort
- access to xmlhttprequest at angular 8
- transform array to string js
- js filter text
- input type shows object angularjs
- regular expression search for any character until Space
- javascript reduce promises
- js does object exist in array
- formidable
- bootstrap 4 hide modal via javascript
- core.js:6228 error typeerror: cannot read property 'height' of undefined
- js console.log color
- laravel json eloquent
- async await in forloops