繁体   English   中英

找不到模块'./auth/auth.service'

[英]Cannot find module './auth/auth.service'

我启动了一个空白的Angular应用程序,并开始遵循Auth0的设置指南 ,选择使用npm install代替使用yarn或包括Auth0的CDN中的脚本。 我在执行ng serve时没有越过以下错误,但没有越过步骤1(标题中的“设置应用程序的代码”):

 ERROR in /Users/g/Documents/Projects/login/src/app/app.component.ts (2,29): Cannot find module './auth/auth.service'.
 ERROR in /Users/g/Documents/Projects/login/src/app/app.component.ts (10,28): Cannot find name 'Authservice'.

这是我的app.component.ts代码(我从Angular的空白设置中修改的唯一代码):

import { Component } from '@angular/core';
import { AuthService } from './auth/auth.service';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  constructor(public auth: Authservice) {
    auth.handleAuthentication();
  }
}

我在这里做错了什么? 该指南的第一步没有很多出错的机会,但是我猜测问题的一部分在于运行npm install --save auth0-js不会在我的项目中放置“ auth”文件夹,并且看来我的app.component.ts文件中的第二行代码正在尝试引用“ auth”文件夹。

@joevern

似乎您正在使用的安装指南不再有效。 这是包文档的更新链接。

https://www.npmjs.com/package/auth0-js

首先,您需要做的就是npm install auth0-js软件包,然后将其导入到您的组件中,如下所示。

import * as auth0 from "auth0-js";

有关如何使用变量auth0的信息,请参阅文档。

Auth0支持将我链接到该解决方案 我无法实现它,因为我无法为我的项目更改回调URI,但我将其留在此处记录。

您必须编写自己的服务,或者可以下载和使用类似以下的库: https : //github.com/cornflourblue/angular-7-registration-login-example/tree/master/src/app/_services

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM