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 ?
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.
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.
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".
This will create a node_modules folder within that directory which should have the @angular/core that's required.
The angular2
name in modules names is for versions before RC (release candidate) versions (beta ones) and the @angular
one for RC versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With