0

So, I'm making a quiz, and I've been wanting to save my answers to a text file. I want to use "Node.js", and I'm worried about this: They only offer an installer to install Node.js on your computer. Since I'm not working with servers or anything like that, and I'm just a hobbyist, the people I might first give this to may not have Node.js installed on their computer. Please do note that this is for a website, not a program.

Is this kind of thing possible to do without the use of a hosting service or a server? :

const lib = require('./libraries/NODE') 

If it is, how would I do it?

Thanks for any help!

  • "I'm not working with servers" -- if you are writing node.js code then you are writing a server. If there is a node.js function you want to use then you will have to write a server in node.js. Node is server-side javascript allowing you to use javascript as a server-side programming language like PHP or Java or C#. Firefox, Chrome, Safari and Edge are all client side javascript environments. If there is something you want to do but not on any server you will have to figure out how to do it in the browser, not node.js – slebetman Jul 24 '20 at 15:40
  • @slebetman, I meant I was not working with physical servers as of yet. – Sumukh Prasad Jul 25 '20 at 02:46

1 Answers1

0

There are two options for you:

  1. I would suggest using something like Electron- which will wrap the node runtime for you - https://www.electronjs.org/docs/tutorial/first-app which you can distribute to people. This will open up all the nodejs related functionality and more for you.

  2. Another answer at SO though old, suggests using window.name vs writing out text files - Javascript/HTML Storage Options Under File Protocol (file://)

You cannot import nodejs runtime into the browser running on a file protocol.

Ramakay
  • 2,919
  • 1
  • 5
  • 21