Unable to read length of undefined property in angular 4

I am brand new in Angular 4 and trying to make a clear basic structure for a simple project. I already tested my project and it works well yesterday. But today, when I open my project and want to do "ng serve", it shows an error below. I don’t know what the problem is.

TypeError: Cannot read property 'length' of undefined at createSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:15457:109) at parseSourceFileWorker (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:15389:26) at Object.parseSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:15338:26) at Object.createSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:15192:29) at VirtualFileStats.getSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\@ngtools\webpack\src\compiler_host.js:66:35) at WebpackCompilerHost.getSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\@ngtools\webpack\src\compiler_host.js:213:38) at findSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:67909:29) at processImportedModules (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:68056:25) at findSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:67937:17) at processSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:67840:27) at processRootFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:67728:13) at C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:67018:60 at Object.forEach (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:1449:30) at Object.createProgram (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:67018:16) at AotPlugin._setupOptions (C:\Users\IR\Desktop\angular-first-project\node_modules\@ngtools\webpack\src\plugin.js:129:28) at new AotPlugin (C:\Users\IR\Desktop\angular-first-project\node_modules\@ngtools\webpack\src\plugin.js:26:14) 

Thanks in advance.

+9
source share
4 answers

I saw such errors in random cases, for example, after moving components to different folders, even after all the links were encoded to fit the new path.

Help restore the project using ng-build .

+6
source

I had the same problem. I suggested that this is a problem with the typewritten version. I also changed by installing the top and bottom versions of the current version, of which they did not work. Finally, a solution from github says: -

There was no environment folder in the project.

one I added that it started to work.

enter image description here

+2
source

yes I changed the folders and got this error. After its creation, he worked

0
source

I had this problem in a development environment in which I run the application using ng serve systemd managed user service. After restarting the user service with systemctl --user restart <myappservice> it started again as expected. This is similar to canceling ng serve and repeating this command.

0
source

Source: https://habr.com/ru/post/1268792/


All Articles