【问题标题】:Module not found: Error: Can't resolve 'http' in selenium-webdriver找不到模块:错误:无法解析 selenium-webdriver 中的“http”
【发布时间】:2018-12-19 14:49:14
【问题描述】:

我发现了这个错误:

./node_modules/selenium-webdriver/http/index.js 中的错误找不到模块:错误:无法解析“/Users/mac/angular/restaurantApp/node_modules/selenium-webdriver/http”中的“https”

谁能帮我解决这个问题。

谢谢

【问题讨论】:

  • 好吧真的很抱歉,因为这是我的错误。我不小心导入了 httpClient 而不是 httpClientModule。

标签: angular6


【解决方案1】:

对于其他访客。我在自定义 servsiv 中添加了 import { HttpClient } from 'selenium-webdriver/http'; 而不是 import { HttpClient } from '../../../node_modules/@types/selenium-webdriver/http';

【讨论】:

    【解决方案2】:

    我也遇到过类似的错误代码问题:

    ERROR in ./src/app/my.service.ts   
    Module not found: Error: Can't resolve '../../node_modules/@types/selenium-webdriver/http' in '...\src\app
    

    问题在于 Visual Studio Code 的 Autoimport 插件从导入 HttpClient 类

    '../../node_modules/@types/selenium-webdriver/http'
    

    而不是

    '../../node_modules/@angular/common/http'
    

    我发现这个问题在某种程度上很有帮助,但它并没有给我一个明确的答案。我发布我发现的内容,以便其他访问者更轻松。

    【讨论】:

    • 我有类似的问题,为什么要从 '/selenium-webdriver/http' 导入?
    • 您可以通过在项目范围内搜索from 'selenium-webdriver/http';来找到发生这种情况的位置
    【解决方案3】:

    解决了在 import { HttpClient, HttpHeaders } from '@angular/common/http' 时更改自动导入做 httpclient;

    【讨论】:

      【解决方案4】:

      意味着改变 从 'selenium-webdriver/http' 导入 { HttpClient }; 从 '@angular/common/http' 导入 { HttpClient };

      【讨论】:

        【解决方案5】:

        我在使用 Angular 和 Laravel 时遇到了同样的问题 我想在app.module.tsmy.component.ts 中添加 HTTP 模块 但它添加到 selenium HTTP 客户端。

        所以我从

        import { HttpClient } from 'selenium-webdriver/http';
        

        import { HttpClientModule} from '@angular/common/http';
        

        【讨论】:

          【解决方案6】:

          我的问题已经通过替换解决了

          =>    import { HttpClient } from 'selenium-webdriver/http';
          to => import { HttpClient } from '@angular/common/http';
          

          来自我在 Angular 7 中的一个 ts 文件

          【讨论】:

            【解决方案7】:

            我的错误是我从selenium-webdriver/http 导入了HttpClient

            import { HttpClient } from 'selenium-webdriver/http';
            

            将此行替换为:

            import { HttpClient } from '@angular/common/http';
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2018-04-12
              • 2018-06-29
              • 1970-01-01
              • 2020-12-15
              • 2017-12-29
              • 2019-10-27
              • 2019-12-01
              相关资源
              最近更新 更多