Read the statement by Michael Teeuw here.
fs.stat SyntaxError: Unexpected token
-
Hello everyone,
I try to apply fs.stat to find if a file exists but I constantly get this error:fs.stat((err) => { ^ SyntaxError: Unexpected token .Can someone help me how to fix it?
-
@pepebc It may depend on what precedes that snippet (if anything). Try copy/pasting the whole file into JSHint, it may give you a better idea. Also, doesn’t
fs.stat()take apathas the first argument? -
Also did you import the fs module correctly?
-
fs is included by default in nmp.
I do tests because I need to verify that a text file exists in the module directory when an attempt was made to create.
I am not an expert in programming and I am trying with the functions that I find online. Always it gives me that error, although in the forums seems to work. In this environment, it gives me problems. -
It may be included by default in Node.js, but you still need to import it into your script.
-
Yes, I had imported it with
const fs = require ('fs');
but I was not creating the function well in the right place. Thank you.
It’s crazy what I want, I know. I want to connect Kalliope (modular always-on voice controlled personal assistant) - https://kalliope-project.github.io with MagicMirror. I find it a very powerful and flexible tool. The program I already manage it well separately and I have created “neurons” and “events” … etc, but it would be wonderful to interact with MagicMirror modules.
Lights, sensors, temperature, webcam, notifications, reading email, music … etc, that I already have it integrated in Kalliope
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login