Tengo un problema cuando intento ejecutar ng serve en un proyecto Angular creado recientemente. La versión que estoy usando es 9.1.4, este error no ocurre en un proyecto con una versión anterior de Angular.
Package Version ----------------------------------------------------------- @angular-devkit/architect 0.901.4 @angular-devkit/build-angular 0.901.4 @angular-devkit/build-optimizer 0.901.4 @angular-devkit/build-webpack 0.901.4 @angular-devkit/core 9.1.4 @angular-devkit/schematics 9.1.4 @angular/cli 9.1.4 @ngtools/webpack 9.1.4 @schematics/angular 9.1.4 @schematics/update 0.901.4 rxjs 6.5.5 typescript 3.8.3 webpack 4.42.0 Después de ejecutar ng serve o ng build :
chunk {main} main.js, main.js.map (main) 2 kB [initial] [rendered]<br> chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 679 bytes [initial] [rendered]<br> chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]<br> chunk {styles} styles.js, styles.js.map (styles) 12.4 kB [initial] [rendered]<br> chunk {vendor} vendor.js, vendor.js.map (vendor) 339 kB [initial] [rendered]<br> Date: 2020-05-08T02:06:46.145Z - Hash: 1a1b937f0ca2bb37634b - Time: 4087ms<br> **ERROR in TypeError: Cannot read property 'flags' of undefined** at resolveAlias (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:36513:37) at checkAliasSymbol (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:64502:26) at checkImportBinding (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:64534:13) at checkImportDeclaration (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:64552:29) at checkSourceElementWorker (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:64961:28) at checkSourceElement (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:64800:17) at Object.forEach (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:317:30) at checkSourceFileWorker (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:65123:20) at checkSourceFile (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:65091:13) at getDiagnosticsWorker (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:65179:17) at Object.getDiagnostics (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:65165:24) at C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:98703:85 at runWithCancellationToken (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:98665:24) at getBindAndCheckDiagnosticsForFileNoCache (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:98691:20) at getAndCacheDiagnostics (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:98956:26) at getBindAndCheckDiagnosticsForFile (C:\Cursos\Angular\ang-hello-world\node_modules\typescript\lib\typescript.js:98688:20) ** **Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/** **El resultado que obtengo en mi navegador después de ejecutar este proyecto es:
Cannot GET /prueba esta solución:
npm install @angular/core@9.1.4 @angular/animations@9.1.4 @angular/common@9.1.4 @angular/forms@9.1.4 @angular/platform-browser@9.1.4 @angular/router@9.1.4 @angular/platform-browser-dynamic@9.1.4 @angular/compiler@9.1.4 @angular/compiler-cli@9.1.4 @angular/language-service@9.1.4 npm install ng serveeditar
Si usa angular 9.1.6, debería estar bien ahora
npm update @angular/cli @angular/corepublicación original
Algo está roto en Angular 9.1.5: si ejecuta lo siguiente, debería funcionar:
npm install @angular/core@9.1.4 @angular/animations@9.1.4 @angular/common@9.1.4 @angular/forms@9.1.4 @angular/platform-browser@9.1.4 @angular/router@9.1.4 @angular/platform-browser-dynamic@9.1.4 @angular/compiler@9.1.4 @angular/compiler-cli@9.1.4 @angular/language-service@9.1.4 ng buildAcabo de pasar alrededor de 4-5 horas tratando de arreglarlo yo mismo...
El problema parece provenir del uso de Angular CLI 9.1.4 con Angular 9.1.5 (lo más probable es que el compilador
Verás el problema cuando lo hagas.
ng --versionSi lo consigues:
Angular CLI: 9.1.4 Node: 12.16.3 OS: win32 x64 Angular: 9.1.5 ... animations, cli, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router Ivy Workspace: YesLuego, deberá seguir las instalaciones de npm que enumeré anteriormente
La respuesta de @Matt también funcionó para mí para ng serve , pero necesitaba pasos adicionales. Primero haga estos pasos "Citando los pasos de su respuesta":
ng --version . Vaya al siguiente paso si obtiene: Angular CLI: 9.1.4 Node: 12.16.3 OS: win32 x64 Angular: 9.1.5 ... animations, cli, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router Ivy Workspace: Yes npm install @angular/core@9.1.4 @angular/animations@9.1.4 @angular/common@9.1.4 @angular/forms@9.1.4 @angular/platform-browser@9.1.4 @angular/router@9.1.4 @angular/platform-browser-dynamic@9.1.4 @angular/compiler@9.1.4 @angular/compiler-cli@9.1.4 @angular/language-service@9.1.4 Un par de pasos más para que más ng serve para finalmente funcionar.
An unhandled exception occurred: Cannot find module 'tslib' Para esto, instalé el paquete tslib manualmente usando npm.You seem to not be depending on "@angular/core" and/or "rxjs". This is an error. . Para esto me refería "Parece que no dependes de" @ angular / core ". ¡y voilá! ng servir funcionó!9.1.6 recién lanzado, debería solucionar ese problema
Tengo el mismo problema al actualizar de 10.1.0 a 11.1.1.
Actualizar TypeScript a la última versión de 4.0.2 a 4.1.3 resolvió el problema:
npm i typescript@latest