在eclipse中运行Protractor会出错

时间:2017-11-03 10:26:14

标签: angularjs protractor

我安装了量角器,但运行脚本时出现以下错误。但是当我从cmd提示符运行时,它运行正常。

SyntaxError:意外的令牌......

at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> 

(\node_modules\protractor\built\configParser.js:6:18)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)

请帮忙......

谢谢, 拉梅什

2 个答案:

答案 0 :(得分:0)

如果您使用了Tern-Plugin,则此插件中有一个内置但旧版本的node.js。 检查你的运行配置,你在那里找到的node.js版本。

如果这还没有解决您的问题,请在您的运行配置中发布一些详细信息,特别是从标签&#34;量角器&#34; node.js的详细信息。

<强>更新

根据您的评论,您使用了内置的node.js版本。

  1. 尝试切换到&#34; Native Node.js&#34;并参考本地或全球安装的node.exe
  2. 由于tern-project存在问题,因此第1点可能无效。在这种情况下,请检查this SO-Question and especially @AngeloZerrs comment to its answer - 它包含所有必需的信息
  3. 作为最后的选择,您可以将node_modules文件夹从您的安装(包含量角器等)复制到您的eclipse工作区。 重要:将此文件夹添加到.gitignore,因为这是环境,而不是代码。此解决方案也是一个肮脏的黑客。正式可用后立即将其替换为Tern-Version 1.3或删除Tern并切换到正常的JavaScript项目(可能需要一段时间,直到量角器再次运行)。

答案 1 :(得分:-1)

我通过替换Eclipse中的node.exe而不选择“ Native node.js”选项,解决了具有Eclipse兼容性问题的最新版本NodeJS(和Protractor版本)的问题。

为量角器配置Eclipse之后,可以在以下位置找到eclipse中的node.exe路径:

Window>Preferences>AngularJS>Protractor (get node.js path from node.js field)

在我的情况下,它位于:C:\ Users \ username \ eclipse \ java-oxygen \ eclipse ....... p2 \ pool \ plugins \ tern.eclipse.ide.server.nodejs。 embed.win32.win32.x86_64_1.2.0.201606160856 \ node-v4.2.4-win32-x86_64 \ node.exe“

替换为计算机中最新的node.exe,该文件可以在“ C:\ Program Files \ nodejs \ node.exe”中找到。

现在,您的日食将与最新版本的NodeJS和Protractor一起运行Protractor。

相关问题