@emrah_asl said in Updating Compliments using a spreadsheet:
fs.writeFile("modules/default/compliments/remotefile.json", compliments, function(err) {
my code in node_helper.js (under compliments folder) are creating file on root normally when you start mm with npm start
don’t make this node_helper.js as MM has a special use for that…
make it createCompliments.js
then the best thing is use the full path for the file
fs.writeFile("/home/pi/MagicMirror/modules/default/compliments/remotefile.json", compliments, function(err) {
how do you start MM?
pm2 start 0 (and it starts on boot too…) If you used the automated install script u would have been prompted to set this up.
(if u want to add it now, you can run the fixuppm2.sh script from here
https://github.com/sdetweil/MagicMirror_scripts
just one line to copy/paste
)
now, if you use pm2, it launches MM by using the installers/mm.sh script. you can add your
node modules/default/compliments/createCompliments.js
to the mm.sh and all will continue as normal.
The second problem , my magic mirror fires electron.js error when I try to create file.
i don’t understand this.
npm start fires electron.js
npm reads the package,json file and looks for the command requested
"scripts": {
"start": "DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron js/electron.js",
the ‘start’ command executes that line.