7

I am new in angular2. I have downloaded angular 2 project and tried to setup. I installed angular cli 1.0.0-rc.2 and when I am doing ng serve it is showing the below error:

Cannot read property 'config' of null TypeError: Cannot read property 'config' of null at Class.run (D:\Sumit\AgulaNew\admin\node_modules\@angular\cli\tasks\serve.js:22:63) at check_port_1.checkPort.then.port (D:\Sumit\AgulaNew\admin\node_modules\@angular\cli\commands\serve.js:103:26) at at process._tickCallback (internal/process/next_tick.js:188:7)

Fruchtzwerg
  • 10,999
  • 12
  • 40
  • 49
Sumit Rawat
  • 151
  • 1
  • 2
  • 4
  • Does whatever you are trying to read 'config' from exist in your system? ie, if it is part of a json object, do you have that stored somewhere it can read it? – Erica Grant Sep 21 '17 at 15:18
  • It is inside @angular cli modules – Sumit Rawat Sep 21 '17 at 16:08
  • Then something might not have installed correctly. What version of node are you using? And if you are new to angular 2 have you considered starting with an angular 4 tutorial and set up instead? – Erica Grant Sep 21 '17 at 16:12
  • i am using node v8.5.0 and npm 5.3.0... and this was an existing big project. – Sumit Rawat Sep 21 '17 at 16:15
  • Could you try updating the cli? I don't know that is what is wrong but it looks like you are running newer versions of node and npm but cli is a little old. – Erica Grant Sep 21 '17 at 16:18
  • No, I have not try yet – Sumit Rawat Sep 21 '17 at 16:22
  • Possible duplicate of [Angular 2 Cannot read property 'config' of null](https://stackoverflow.com/questions/42835118/angular-2-cannot-read-property-config-of-null) – ishandutta2007 Nov 20 '17 at 03:39

3 Answers3

10

I had the same error this morning.

You probably copied your project from one folder to another using Finder or Explorer. If so, the file .angular-cli.json is missing.

If you are using a Mac, use the command ls -a to list hidden files. You will notice that .angular-cli.json will be there. Just copy the file to the new location and your problem will be solved.

Otacilio Oliveira
  • 686
  • 1
  • 5
  • 15
3

I once git cloned a project where

ng -serve 

failed.

This was because .angular-cli.json was missing.

On the other and

npm start

did the job instead ;-)

Typically the project from angular tutorial webpack guide downloadable from webpack.zip confirms the case

user1767316
  • 3,276
  • 3
  • 37
  • 46
2

Cannot read property 'config' of null is a typical error when .angular-cli.json is missing.

BTW you do not need any seed projects as a base for your new app and there is no reason to use outdated angular cli 1.0.0-rc.2 as you mention.

Check the latest releases https://github.com/angular/angular-cli/releases or with npm show @angular/cli version then install the latest npm install -g @angular/cli and generate a new project with that. To see your local CLI version run ng -v

Also checkout the recent article The Past, Present, and Future of the Angular CLI by one of the core Angular team mebers @StephenFluin

angularrocks.com
  • 26,767
  • 13
  • 87
  • 104