【问题标题】:Angular 2 + Auth0 (Could not find a declaration file for module 'auth0-js'. )Angular 2 + Auth0(找不到模块'auth0-js'的声明文件。)
【发布时间】:2017-12-08 06:07:32
【问题描述】:

找不到模块“auth0-js”的声明文件。 'C:/sandbox/loginauth0/node_modules/auth0-js/src/index.js' 隐含了一个 'any' 类型。

我想使用 auth0 登录。但是在按照说明构建我自己的 Angular 2 服务之后。

从 'auth0-js' 导入 * 作为 auth0;

给出一个类似上面的错误。但我把它和“npm install --save auth0-js”放在我的node_modules中

【问题讨论】:

    标签: angular auth0


    【解决方案1】:

    首先,请务必关闭 tsconfig.json 中的 noImplicitAny 属性。

    然后,验证您是否按照此处的步骤操作:https://auth0.com/docs/quickstart/spa/angular2

    【讨论】:

      【解决方案2】:

      Auth0.js 还没有提供 TypeScript 类型定义文件。您可以尝试使用:

      const auth0 = require('auth0-js');
      

      或者在tsconfig.json 文件中将noImplicitAny 标志转换为false 的更暴力方法,但这会关闭整个项目的警告/错误。查看更多信息here

      【讨论】:

      • 感谢您的帮助。但它仍然无法正常工作。它仍然说 404 GET /node_modules/auth0-js/index.js 。我什至尝试在我的 systemjs.config.js 中输入:'auth0-js': 'node_modules/auth0-js/index.js'
      • 我也面临同样的问题。我得到 404。文件在它的位置。
      猜你喜欢
      • 2019-10-27
      • 1970-01-01
      • 2017-04-03
      • 2018-03-13
      • 2021-11-30
      • 2020-11-25
      • 2018-11-12
      • 2017-08-13
      • 2016-12-25
      相关资源
      最近更新 更多