Angular2 - npm install没有找到命名空间webdriver

时间:2016-12-20 09:04:52

标签: angular typescript npm npm-install

重新启动Angular2项目后,我已启动命令npm install并出现以下错误:

node_modules/protractor/built/browser.d.ts(258,37): error TS2503: Cannot find namespace 'webdriver'

任何人都知道它来自哪里/如何修复它?

感谢你,

2 个答案:

答案 0 :(得分:22)

更新21-12-2016:从量角器4.0.14开始修复。

量角器依赖于selenium-webdriver:

' @ types / selenium-webdriver':' ~2.53.31',

不幸的是,https://github.com/DefinitelyTyped/DefinitelyTyped/pull/13382昨天合并,并以2.53.37发布。

临时修复:手动安装版本2.53.36修复了问题,直到量角器发布了包含selenium-webdriver包中的更改的新版本。

npm install @types/selenium-webdriver@2.53.36 --save-dev

并在修正量角器后立即删除dev依赖项。

有一个PR待处理:https://github.com/angular/protractor/pull/3848

答案 1 :(得分:0)

对于那些在升级到Protractor 4.0.14后仍然遇到问题的人,我发现引用webdriver的类现在需要一个import语句:

require_once $_SERVER['DOCUMENT_ROOT'] . '/SQL.php';
use myDatabase\SQL;
$rand = 0;
$group = variable_get('govdocs_images_group');
// get ids of images in this group
$images = SQL::select('SELECT `id`, `link` FROM `govdocs_images` WHERE `group` = FROM_UNIXTIME(' . $group . ')');
// pick a random number between 0 and $image_count - 1 for seeking.
if(count($images) > 1) {
   $rand = rand(0, count($images)-1);
}
// print link and image.   
   echo '<a href="' . $images[$rand]['link'] . '">';
   echo '<img src="/myFilePath/img.php?id=' . $images[$rand]['id'] . '"/>';
   echo '</a>';

希望能帮助任何有同样问题的人。