Electron and node.js problem


#1

Hey, I am pretty new to electron and node.js I am following a tutorial of how to make a shopping list application but when I try to run it (use: “npm start”), it says this: https://pastebin.com/RadEeft0.
This is my code: https://pastebin.com/V3Up4M0T.

Can someone help me?


#2

I suggest looking on line 56 for an unexpected semicolon.

In this case in particular, you are making an object. Objects take keys and values; syntactic sugar lets you pass the single “thing” if both the key name is the same as the value. However, it does not make sense to run a function inside an object you are creating in that way.


#3

I don’t really think I understand but I watched a video that teach how to use electron and he did the exact same and it worked just fine… If you know what I can do I will really appreciate this.


#4

Error, because we are executing a function

{
  myFunction()
}

Fine, because we are defining a method

{
  myMethod() {
    return "foo"
  }
}

As for your exact copying, I too sometimes think the error must lie with the interpretor / compiler. Alas, I always find it was my own mistake. With what I said above in mind, I recommend watching that part again closer. I see, even in the pastebin you provided, that the instructor is using a different style:

            {
                label:'Quit',
                accelerator: process.platform == 'darwin' ? 'Command+Q' : 'Ctrl+Q',
                click()
                {
                    app.quit();
                }
            }

Here, click() is also a method definition like I showed above.