Search code examples
node.jsblockchainethereumsoliditytruffle

Truffle: "Invalid or unexpected token" when running promise function


When I run any function in the truffle console, it returns "Invalid or unexpected token."

This is the full error return:

truffle(development)> app.candidates(1).then(function(c) {candidate = c;})
SyntaxError: Invalid or unexpected token
at REPLServer.Interface._onLine (readline.js:280:10)
at REPLServer.emit (events.js:211:7)
at emitOne (events.js:116:13)
at REPLServer.onLine (repl.js:468:10)
at REPLServer.runBound [as eval] (domain.js:314:12)
at bound (domain.js:301:14)
at ReplManager.interpret (C:\Users\Jakob\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\repl.js:119:1)
at Console.interpret (C:\Users\Jakob\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\console.js:164:1)
at Object.runInContext (vm.js:119:10)
at createScript (vm.js:80:10)

I just started my first dApp project following a tutorial on YouTube and am fairly new to this. If any more information is required, ask and I will help you out.

So far I tried the same setup on my Mac OSX and it worked perfectly fine. Could it be a step I'm missing on windows or a missing dependency?

Thank you for any help in advance!


Solution

  • Although it is not really answering why your syntax error occurs, it seems to be a Windows specific problem on node.js, probably related to encoding.

    These kind of problem can be easily avoided using Bash on Windows 10. https://learn.microsoft.com/en-us/windows/wsl/install-win10