Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular EventEmitter not found

I created a project by using Angular CLI, but when I try to use EventEmitter, it fails to compile with the error "Can't resolve '@angular/core/src/event_emitter'"

Here is the full error message

Failed to compile.

./src/app/app.component.ts
Module not found: Error: Can't resolve '@angular/core/src/event_emitter' in 'C:\xampp\htdocs\myapp\src\app'
@ ./src/app/app.component.ts 10:22-64
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

Here is the code.

import { Component } from '@angular/core';
import { EventEmitter } from '@angular/core/src/event_emitter';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  private eventemitter = new EventEmitter<string>();
  title = 'My Application';
}

The file "node_modules\@angular\core\src\event_emitter.d.ts" exits.

I deleted node_modules folder, cleared npm cache (by using --force) and reinstalled all modules again with npm install, but still getting the same error.

I have no idea what can cause this, and I unfortunately couldn't find anything on internet related to this. Any help would be appreciated.

like image 581
reika Avatar asked Dec 22 '17 20:12

reika


1 Answers

Try this:

import { EventEmitter } from '@angular/core';
like image 66
Uğur Dinç Avatar answered Oct 21 '22 07:10

Uğur Dinç