0

Observem meu projeto Front-end feito em Angular

Brewer-ui

Agora observem meu projeto Back-end Java com Spring Boot

Brewer

Não se preocupem com meu projeto Back-end, ele está funcionando bem, o problema é meu projeto Front-end feito em angular, estou tentando carregar uma grid e não estou conseguindo porque está gerando um erro no consoles do Angular, mas antes observe os arquivos que fiz alteração.

Veja meu projeto rodando antes das alterações:

inserir a descrição da imagem aqui

Arquivo app.modules.ts Antes:

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    EstilosModule,
    CoreModule,
    CevejasModule,
    ClientesModule,
    UsuariosModule,

    BrowserAnimationsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Depois das alterações:

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    EstilosModule,
    CoreModule,
    CevejasModule,
    ClientesModule,
    UsuariosModule,
    HttpModule,
    BrowserAnimationsModule
  ],
  providers: [EstiloService],
  bootstrap: [AppComponent]
})
export class AppModule { }

Arquivo EstiloPesquisaComponent Antes:

export class EstiloPesquisaComponent {

}

Depois das alterações:

export class EstiloPesquisaComponent implements OnInit{


estilos = [];
constructor(private estiloService: EstiloService){ }

ngOnInit() {
     this.pesquisar();
  }
  pesquisar() {
     this.estiloService.pesquisar()
       .then(estilos => this.estilos = estilos);
   }

}

Eu acho que meu problema está nesse código abaixo:

Arquivo EstiloService

Antes:

@Injectable()
export class EstiloService {

}

Depois das alterações:

@Injectable()
export class EstiloService {

  estilosUrl = 'http://localhost:8080/estilos';

  constructor(private http: Http) { }

  pesquisar(): Promise<any> {
    return this.http.get(`${this.estilosUrl}`)
    .toPromise()
    .then(response => {
        console.log(response.json());
        });
    }

}

Depois que faço as alterações ele gera esse erro:

ERROR in ./src/app/app.module.ts
Module not found: Error: Can't resolve '@angular/http/src/http_module' in 'C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\app'
resolve '@angular/http/src/http_module' in 'C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\app'
  Parsed request is a module
  using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\package.json (relative path: ./src/app)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\package.json (relative path: ./src/app)
    resolve as module
      C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\app\node_modules doesn't exist or is not a directory
      C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\node_modules doesn't exist or is not a directory
      C:\Users\Wladimir\Desktop\projeto cervejaria\node_modules doesn't exist or is not a directory
      C:\Users\Wladimir\Desktop\node_modules doesn't exist or is not a directory
      C:\Users\Wladimir\node_modules doesn't exist or is not a directory
      C:\Users\node_modules doesn't exist or is not a directory
      C:\node_modules doesn't exist or is not a directory
      looking for modules in C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules
        using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\package.json (relative path: ./node_modules)
          using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\package.json (relative path: ./src/http_module)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module.js doesn't exist
            as directory
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module doesn't exist
      looking for modules in C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules
        using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\package.json (relative path: ./node_modules)
          using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\package.json (relative path: ./src/http_module)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module.js doesn't exist
            as directory
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module doesn't exist
      looking for modules in C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src
        using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\package.json (relative path: ./src)
          using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\package.json (relative path: ./src/@angular/http/src/http_module)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module.js doesn't exist
            as directory
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module doesn't exist
      looking for modules in C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src
        using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\package.json (relative path: ./src)
          using description file: C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\package.json (relative path: ./src/@angular/http/src/http_module)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module.js doesn't exist
            as directory
              C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module doesn't exist
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\app\node_modules]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\node_modules]
[C:\Users\Wladimir\Desktop\projeto cervejaria\node_modules]
[C:\Users\Wladimir\Desktop\node_modules]
[C:\Users\Wladimir\node_modules]
[C:\Users\node_modules]
[C:\node_modules]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module.ts]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module.js]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module.ts]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module.js]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\node_modules\@angular\http\src\http_module]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module.ts]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module.js]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module.ts]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module.js]
[C:\Users\Wladimir\Desktop\projeto cervejaria\brewer-ui\src\@angular\http\src\http_module]
 @ ./src/app/app.module.ts 17:0-59
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

Eu acredito que o problema esteja no arquivo EstiloService.

Alguém poderia verificar onde errei por favor?

Seguindo a sugestão do @André Roggeri Campos

fiz as alterações sugeridas, mas gerou esse erro:

ERROR in src/app/estilos/estilo.service.ts(2,10): error TS2305: Module '"C:/Users/Wladimir/Desktop/projeto cervejaria/brewer-ui/node_modules/@angular/http/src/http_module"' has no exported member 'Http'.

não funcionou!

1 Resposta 1

0

Algum dos seus imports parece estar errado.

Já reparei que muitas vezes o Intelisense do Visual Code importa os modulos do Angular incorretamente.

Substitua o @angular/http/src/http_module por @angular/http

3
  • deu um erro diferente, eu acho que o problema não é a importação.
    – user10264
    9/01/2018 às 9:12
  • se você verificar esse modelo e projeto do github ele fez a mesma importação github.com/algaworks/curso-angular-rest-spring-boot-ui/blob/…
    – user10264
    9/01/2018 às 9:15
  • conseguir corrigir o problema, o problema foi na importação no arquivo do modulo, eu troquei esse import { HttpModule } from '@angular/http/src/http_module'; por esse import { HttpModule } from '@angular/http'; mas de qualquer forma sua dica ajudou, muito obrigado.
    – user10264
    9/01/2018 às 9:20

Você deve fazer log-in para responder a esta pergunta.