Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module @angular/core + angular2

Tags:

angular

I am trying to create an Angular 2 application using Typescript in Visual Studio 2015. I have installed npm on my machine. When I compile my application , I am getting errors cannot find module '@angular/core'. It is referred in all the ts files under the node_modules folder in the import statement. For e.g.

import { ElementRef, AfterViewInit, OnDestroy, DoCheck, EventEmitter, IterableDiffers } from '@angular/core';

I am currently getting around 500 plus errors. The error goes off when I replace it with 'angular2/core '. Also just to let you know , I am using PrimeNG UI Components in my project as well.

Could somebody help ? I don't understand why it is looking at @angular/core ?

like image 350
Tom Avatar asked May 13 '16 14:05

Tom


People also ask

Can't find module angular Devkit build angular?

To solve the error "Could not find module '@angular-devkit/build-angular'", make sure to install the package by opening your terminal in your project's root directory and running the following command: npm i -D @angular-devkit/build-angular and restart your IDE and development server.

Can not find module or its corresponding type declarations?

The "Cannot find module or its corresponding type declarations" error occurs when TypeScript cannot locate a third-party or local module in our project. To solve the error, make sure to install the module and try setting moduleResolution to node in your tsconfig. json file.

How do I run an angular project in Visual Studio?

Now open Visual Studio Code. Go to "File" > "Open Folder" and select "First-Angular-Project" from the "Desktop". Now in the "TERMINAL" run ng new Angular-Project-Demo. Whenever it prompts with something like "Would you like to add Angular routing? (y/N)" press "y" and hit "ENTER".


2 Answers

  1. Install nodejs
  2. Open cmd prompt and type 'cd your project directory'
  3. Type 'npm install' and hit enter.

This will create a node_modules folder within that directory which should have the @angular/core that's required.

like image 100
User123 Avatar answered Sep 27 '22 22:09

User123


The angular2 name in modules names is for versions before RC (release candidate) versions (beta ones) and the @angular one for RC versions.

like image 34
Thierry Templier Avatar answered Sep 27 '22 22:09

Thierry Templier