I have encountered an issue while setting up a new Angular2 app from the quickstart folder on the Angular website. Despite following all suggested solutions, I am still facing errors. After running npm install
, everything seems fine as I can see my node_modules folder at the root level.
However, when I try to execute ng serve
, I receive the following error messages :
ERROR in angular/src/app/app.component.ts (1,27): Cannot find module '@angular/core'.
ERROR in angular/src/app/app.component.ts (8,14): Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.
ERROR in angular/src/app/app.module.ts (1,31): Cannot find module '@angular/platform-browser'.
ERROR in angular/src/app/app.module.ts (2,26): Cannot find module '@angular/core'.
ERROR in angular/src/app/app.module.ts (16,14): Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.
ERROR in angular/src/main.ts (1,32): Cannot find module '@angular/core'.
ERROR in angular/src/main.ts (2,40): Cannot find module '@angular/platform-browser-dynamic'.
Here is the structure of my folders :
https://i.sstatic.net/fnEvm.jpg
And here is my tsconfig.json :
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"../node_modules/@types/"
]
},
"compileOnSave": true,
"exclude": [
"node_modules/*",
"**/*-aot.ts"
]
}
Edit :
This is my app.module.ts
:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }