I have read several similar questions here on SO but couldn't find any answer that fits my case. I am new to angularjs and nodejs, and I am stuck here: I would like to store the input of a form into a json file. For that I found out about this procedure:
var fs = require('fs');
fs.appendFile('../database/lexicon.json', ' This is my text.', function (err) {
if (err) throw err;
console.log('Updated!');
});
I am just testing here with 'This is my text', and my json file is located here ../database/lexicon.json
But the issue comes from the fact that my program doesn't recognise the require
.
I understand that it is a server side action and that it can not run in the browser, but I thought I would overcome that issue by running my app in a local server with this command:
npx http-server -o
Can anyone help me out with this issue? Thanks!
OK, I solved the problem, not with this example, but I moved on to another feature of my app that require another require
and I don't get the error message anymore after installing express.js
!
I hope this will help others.