angular / quickstart

Angular QuickStart - source from the documentation
MIT License
3.11k stars 3.14k forks source link

"Cannot read property 'config' of null" while running "ng build" #466

Closed senglory closed 7 years ago

senglory commented 7 years ago

I pulled the latest version of the project and issued the following commands:

cd quickstart npm install npm install --save-dev @angular/cli npm install --save-dev @angular/compiler-cli

Then I tried to run "ng build --verbose" and got the following weird error:

Cannot read property 'config' of null TypeError: Cannot read property 'config' of null at Class.run (C:\tmp\ang\quickstart\node_modules\@angular\cli\tasks\build.js:15:56) at Class.run (C:\tmp\ang\quickstart\node_modules\@angular\cli\commands\build.js:149:26) at Class.Command.validateAndRun (C:\tmp\ang\quickstart\node_modules\@angular\cli\ember-cli\lib\models\command.js:128:15) at C:\tmp\ang\quickstart\node_modules\@angular\cli\ember-cli\lib\cli\cli.js:92:22 at tryCatch (C:\tmp\ang\quickstart\node_modules\rsvp\dist\rsvp.js:539:12) at invokeCallback (C:\tmp\ang\quickstart\node_modules\rsvp\dist\rsvp.js:554:13) at C:\tmp\ang\quickstart\node_modules\rsvp\dist\rsvp.js:629:16 at flush (C:\tmp\ang\quickstart\node_modules\rsvp\dist\rsvp.js:2414:5) at _combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickCallback (internal/process/next_tick.js:98:9)

What I'm doing wrong?

DavidIsrawi commented 7 years ago

Same issue was discussed here: https://github.com/angular/angular-cli/issues/4736

I'm also struggling to make it work..

CoreyNelson commented 7 years ago

Same issue when I try to 'ng build' this Visual Studio Template.

Foxandxss commented 7 years ago

You can't do this stuff here. The quickstart is a systemjs project. You can't convert it to CLI just by installing two packages.

gronel commented 7 years ago

Same of my how to resolve this issue?

manoj-raghuvanshi commented 7 years ago

I got the similar issue , but resolved it by adding .angular-cli.json file at root level (As I creted a diffrent repo by just copying the existing angular project) .it was missing in my case and I didnt created project using cli

ppgowda4 commented 7 years ago

I got similar issue and resolved it by adding .angular-cli.json file.

ramseyjiang commented 7 years ago

@ppgowda4 I got the same issue and I didn't solve it. Can you tell me where did you create that json file? I mean what's the exact path of it? And what's the content of it?

blidkid commented 7 years ago

Same problem.

Solution copy .angular-cli.json from you angular folder

and change root path to be adequate.

Foxandxss commented 7 years ago

Why are you people trying to do "ng build" here? This is not a cli project nor is meant to be

blidkid commented 7 years ago

Well in my case i was Trying to do a ng serve

Foxandxss commented 7 years ago

nor ng serve. This is a completely different thing

shubhaem commented 7 years ago

I get the same error while running "ng serve" where to copy .angular-cli.json file?

Foxandxss commented 7 years ago

Don't do it.

shubhaem commented 7 years ago

What can be the possible solution?

Foxandxss commented 7 years ago

to what problem?

shubhaem commented 7 years ago

when i enter 'ng serve'

Cannot read property 'config' of null TypeError: Cannot read property 'config' of null at Class.run (C:\Users\Shubham Kamath\Desktop\Projects\web-chat\node_modules\@angular\cli\tasks\serve.js:23:63) at check_port_1.checkPort.then.port (C:\Users\Shubham Kamath\Desktop\Projects\web-chat\node_modules\@angular\cli\com mands\serve.js:114:26) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7)

Foxandxss commented 7 years ago

And why are you running ng serve?

blidkid commented 7 years ago

"Ng serve" is to start the agunlar application. I dont understand your question Foxandxss. Thats when people are experiencing issues.

So if you dont use ng serve what do you use?

Foxandxss commented 7 years ago

No, ng serve is a command that the Angular CLI applications have. This is not an Angular CLI application so that command doesn't exist.

It is like trying to use a plane like if it were a car. They both travels, but they are different things.

This starter has a npm start for starting a server.

shubhaem commented 7 years ago

I'm learning Angular and was going through a tutorial. This is Angular-Firebase application. I figured out that .angular-cli.json file was moved. Now pasted it back and it's working. Thanks!

Foxandxss commented 7 years ago

I feel like I am invisible. Don't use this project like a CLI application, I created this repo, I know what I am talking about.

It is up to you.

What is that tutorial @shubhaem ?

ruelcena commented 7 years ago

Thanks Sir Foxandxss for npm start

felix9607 commented 7 years ago

@Foxandxss omg ty... yesterday was everything fine, but today i totally forgot, that I started the Project with "npm start" and tried "ng serve"... shame on me

marslan2037 commented 7 years ago

@Foxandxss i understand what you mean, so what we do to deploy application?

adamnurdin01 commented 7 years ago

you need .angular-cli.json to run "ng serve""

like this, save as .angular-cli.json

{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "project": { "name": "win" }, "apps": [ { "root": "src", "outDir": "dist", "assets": [ "assets", "favicon.ico" ], "index": "index.html", "main": "main.ts", "polyfills": "polyfills.ts", "test": "test.ts", "tsconfig": "tsconfig.app.json", "testTsconfig": "tsconfig.spec.json", "prefix": "app", "styles": [ "styles.scss" ], "scripts": [], "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } } ], "e2e": { "protractor": { "config": "./protractor.conf.js" } }, "lint": [ { "project": "src/tsconfig.app.json" }, { "project": "src/tsconfig.spec.json" }, { "project": "e2e/tsconfig.e2e.json" } ], "test": { "karma": { "config": "./karma.conf.js" } }, "defaults": { "styleExt": "scss", "component": {} } }

Foxandxss commented 7 years ago

@marslan2037 This project is not optimized for deployments, it says so in the readme. It is a demo project for the docs, not to create your own applications.

@adamnurdin01 I said it already, but don't do that.

sharanagouda commented 6 years ago

After trying ng serve I am getting bellow error message

As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release, which will only support Node 6.9 and greater. This package will be officially deprecated shortly after.

To disable this warning use "ng set --global warnings.packageDeprecation=false".

Parsing angular-cli.json failed. Please make sure your angular-cli.json is valid JSON. Error: SyntaxError: Unexpected token  in JSON at position 0 npm ERR! Test failed. See above for more details.

vad1986 commented 6 years ago

npm start doesnt solve the problem.. can anyone help with this?

vad1986 commented 6 years ago

Fixed this issue in my case...If you are moving your project through zip file then 1.move the zip file to the wanted folder 2. unzip the project 3.run npm install 4. run npm start .. hope this helps

polyglotinc commented 6 years ago

OK, since I found this page, like apparently many others looking for "ng serve/build" with null config error, I will add my 2 cents here too so it will be seen... When I saw the bit about the .angular-cli.json file being missing, I realized My problem was I had (unusual for me) copied the listed contents of one project folder into another via the Mac OSX Finder, WHICH DOESN'T SHOW THE ".whatever" (i.e. hidden) FILES!! (arrg). (Normally, I do that sort of thing via Eclipse which does show those files.)

starikovs commented 6 years ago

I had the same problem and red some suggestions here. So, I just generated a new temporary app with help of CLI and copied .angular-cli.json to the current project and it started to work!

Shankar016 commented 6 years ago

Mine is an npm project, I am trying to do an AOT compilation of my project since that facility is not available in npm, am converting it to an 'angular.cli' based,

bghanchi commented 6 years ago

thank Foxandxss sir npm start is working

bghanchi commented 6 years ago

final complated

snehagokarn commented 6 years ago

Its because it's searching for the angular-cli.json and it can't find it. adding it back should work.

pushkalb123 commented 6 years ago

In project folder, renaming the file _angular-cli.json to .angular-cli.json solved this issue.

yeyeyerman commented 4 years ago

I got the similar issue , but resolved it by adding .angular-cli.json file at root level (As I creted a diffrent repo by just copying the existing angular project) .it was missing in my case and I didnt created project using cli

The solution for me was this one. If you are creating the image with Docker, make sure .angular-cli.json is not in your .dockerignore file