0

I'm looking for a method to create + write a text file using JavaScript but I only found method with browser. I don't need my browser to do that, I want to implement a method in my code that write data in a text file nothing to do with the browser.

So someone know how to do this ?

6
  • 3
    Do you mean using node.js? Commented Feb 8, 2017 at 11:21
  • 1
    There are dozens of tools that execute JavaScript without using a browser. You're question boils down to asking for a recommendation for which tool to use to run the JS. Shopping questions are off-topic for Stackoverflow. Commented Feb 8, 2017 at 11:22
  • @Quentin I don't really understand your first sentence I mean why you tell me that but I agree that maybe it's off-topic Commented Feb 8, 2017 at 11:25
  • 3
    stackoverflow.com/questions/2496710/writing-files-in-node-js this question answer perfectly about my problem. I think @emiliopedrollo you should put an answer because I have find it with your hint about node.js Commented Feb 8, 2017 at 11:29
  • 1
    @Jerome you could accept Andrew Monks answer as he already did one that points to the right way. Commented Feb 8, 2017 at 11:43

1 Answer 1

2

Use Node.Js:

Node.js Write a line into a .txt file

Something like:

var fs = require('fs')

var logger = fs.createWriteStream('log.txt', {
  flags: 'a' // 'a' means appending (old data will be preserved)
})

logger.write('some data') // append string to your file
logger.write('more data') // again
logger.write('and more') // again

https://nodejs.org/api/fs.html

Sign up to request clarification or add additional context in comments.

4 Comments

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
Amended my answer. Thanks
Thank you it's better now ! Have a nice day
Thanks. This helps understand the answer much better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.