松露:运行promise函数时出现“无效或意外的令牌”

时间:2018-07-27 15:03:38

标签: node.js blockchain ethereum solidity truffle

当我在松露控制台中运行任何功能时,它将返回“无效或意外的令牌”。

这是完整的错误返回:

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)

我刚刚按照YouTube上的教程开始了我的第一个dApp项目,对此还很陌生。如果需要更多信息,请询问,我会帮助您。

到目前为止,我在Mac OSX上尝试了相同的设置,并且运行良好。这可能是我在Windows上缺少的步骤还是缺少的依赖项?

谢谢您的帮助!

1 个答案:

答案 0 :(得分:1)

尽管它并不能真正回答您为什么会出现语法错误,但这似乎是Node.js上Windows特有的问题,可能与编码有关。

使用Windows 10上的Bash可以轻松避免此类问题。 https://docs.microsoft.com/en-us/windows/wsl/install-win10