Cannot read property 'config' of null
Asked Answered
W

3

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)

Winstead answered 21/9, 2017 at 15:6 Comment(7)
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?Clothesbasket
It is inside @angular cli modulesWinstead
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?Clothesbasket
i am using node v8.5.0 and npm 5.3.0... and this was an existing big project.Winstead
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.Clothesbasket
No, I have not try yetWinstead
Possible duplicate of Angular 2 Cannot read property 'config' of nullKrebs
M
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.

Magpie answered 3/10, 2017 at 16:56 Comment(0)
J
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

Jerkin answered 21/10, 2017 at 11:2 Comment(0)
S
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

Sinusitis answered 21/9, 2017 at 23:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.