【问题标题】:Nativescript Cannot find module 'nativescript-angular/http'Nativescript 找不到模块“nativescript-angular/http”
【发布时间】:2017-01-02 14:11:21
【问题描述】:

我在这里学习 NativeScript 教程:

Native Script Angular - Chapter 3

我在尝试导入 nativescript-angular/http 时出错。它说找不到模块'nativescript-angular/http'。我错过了什么吗?我注意到 node_modules/native-script-angular/http.js 下没有http.js

任何帮助将不胜感激。

【问题讨论】:

  • 你尝试安装 npm 包了吗?
  • 您好 scokmen,不知道您的意思是什么,但我按照教程并通过 NPM 安装了 NativeScript。所以我猜npm包已经安装了,对吧?
  • 在项目的根目录下运行npm i?
  • 另外,你有参考文件吗?
  • 我试过这个@GeorgeEdwards 但它什么也没做。

标签: angularjs angularjs-directive nativescript


【解决方案1】:

请将您的 angular 和 nativescript 升级到当前版本;如果您遇到困难,我可以帮助您做到这一点

【讨论】:

    【解决方案2】:

    尝试查找 NativeScriptHttpClientModule 并不足以为我解决此问题。我还必须从最后删除“/http”。它能够在 'nativescript-angular' 目录中找到模块,而无需引用子目录。

    import { NativeScriptHttpClientModule } from "nativescript-angular"
    

    【讨论】:

      【解决方案3】:

      我很确定您使用的 Angular 版本不再支持'http' 服务,请尝试改用'http-client'

      import { NativeScriptHttpClientModule } from "nativescript-angular/http-client";
      

      或者使用 Angular 5 或更早的版本。

      【讨论】:

        【解决方案4】:

        您在文件 app.module.ts 中包含下一个“NativeScriptHttpModule”

        【讨论】:

          【解决方案5】:

          我遇到了类似的问题。我所要做的就是删除package-lock.json 文件以及我的node_modules 文件夹和之后的npm install

          【讨论】:

            【解决方案6】:

            您只需在杂货文件夹中运行以下命令即可更新版本。

            $ npm install -g npm-check-updates
            $ npm-check-updates -u
            $ npm install 
            

            当 package.json 更新为以下内容时,它对我有用

              "dependencies": {
            "@angular/common": "2.0.0-rc.5",
            "@angular/compiler": "2.0.0-rc.5",
            "@angular/core": "2.0.0-rc.5",
            "@angular/http": "2.0.0-rc.5",
            "@angular/platform-browser": "2.0.0-rc.5",
            "@angular/platform-browser-dynamic": "2.0.0-rc.5",
            "@angular/platform-server": "2.0.0-rc.5",
            "@angular/router": "3.0.0-rc.1",
            "tns-core-modules": "2.2.1",
            "nativescript-angular": "0.3.1"
            },
            

            如果您比较版本,您将看到 NS _HTTP_PROVIDERS 在当前主服务器中,但不在示例中包含的 2.0.0 版本中

            https://github.com/NativeScript/nativescript-angular/blob/master/nativescript-angular/http/ns-http.ts

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2020-11-20
              • 1970-01-01
              • 2021-04-13
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多