angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

TypeError: Cannot read property 'config' of null

Open soodvarun opened this issue 9 years ago • 62 comments

Please provide us with the following information:

OS?

Windows 7

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

@angular/cli: 1.0.0-beta.31
node: 6.9.4
os: win32 x64
@angular/cli: 1.0.0-beta.31
@angular/common: 2.2.4
@angular/compiler: 2.2.4
@angular/compiler-cli: 2.4.7
@angular/core: 2.4.7
@angular/forms: 2.2.4
@angular/http: 2.2.4
@angular/platform-browser: 2.2.4
@angular/platform-browser-dynamic: 2.2.4
@angular/router: 3.2.4
@angular/upgrade: 2.2.4

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

Added cli later and did ng init

The log given by the failure.

Normally this include a stack trace and some more information.

ng build --prod --verbose
Cannot read property 'config' of null
TypeError: Cannot read property 'config' of null
   at Class.run (C:\Projects\Someplace\Portal\Someplace\node_modules\@angular\cli\tasks\build.js:14:89)
   at Class.run (C:\Projects\Someplace\Portal\Someplace\node_modules\@angular\cli\commands\build.js:49:26)
   at Class.<anonymous> (C:\Projects\Someplace\Portal\Someplace\node_modules\@angular\cli\ember-cli\lib\models\command.js:134:17)
   at process._tickCallback (internal/process/next_tick.js:103:7)

Mention any other details that might be useful.

The offending line const outputPath = runTaskOptions.outputPath || config_1.CliConfig.fromProject().config.apps[0].outDir;


Thanks! We'll be in touch soon.

soodvarun avatar Feb 16 '17 08:02 soodvarun

These responses helped me identify the solution. I have an older version of angular, and I pulled teammates code and got this error.

In my project root I had _angular-cli.json - I changed it to .angular-cli.json and it worked!

jzapantis avatar Oct 26 '17 13:10 jzapantis

I had same problem with @angular/cli: 1.0.0 node: 6.10.3 os: win32 x64

first i tried with command "ng init" and ng build. It didn't worked. In my case I just restarted the "Visual Studio code" it worked.

nirmalk31 avatar Oct 30 '17 17:10 nirmalk31

@soodvarun @ardiadrianadri @bougnat12 @jdschmitt @dpalita

Guys first of all try to check whether the the given file is there or not in the below project specified path. file name : .angular-cli.json note :

  1. This .angular-cli.json file should must be there. It should be .angular-cli.json only,not like (_ angular-cli.json) or anything else.

Check the screenshot :+1:

image

The reason why it is showing error is basically due to above two mentioned points :

image

I hope it may help you guys!! :+1: :-)

09abhishek avatar Nov 04 '17 19:11 09abhishek

It was caused due to missing .angular-cli.json as I created my repo in Linux environment and then was trying to run it in the windows environment by cloning the repo.

django18 avatar Dec 12 '17 16:12 django18

Got same issue. Cause of this error: Copying project files from old directory to another directory, .angular-cli.json not copied. Solved: By copying .angular-cli.json file from old project directory to new one. Project building successfully.

narendrasinghrathore avatar Jan 01 '18 05:01 narendrasinghrathore

Got the same issue today. macOS Sierra (10.12.6) Node v9.4.0 ngCli 1.6.5

Pulled a 3 month old NG app from a repo.

Fix: I created a new App using "ng new foo" and copied the .angular-cli.json file form the new project into the cloned existing one.

Quentinb avatar Jan 24 '18 09:01 Quentinb

Same issue. I solved by this one: https://stackoverflow.com/questions/45207900/how-to-generate-angular-cli-json-file-in-angular-cli

kryaksy avatar Jan 28 '18 01:01 kryaksy

Hit the same issue as @narendrasinghrathore @django18, due to missing .angular-cli.json (when copying on macosx finder these .abc files are not visible). Copying the file manually resolved this issue.

humanborg avatar Feb 11 '18 19:02 humanborg

My solution was embarrassingly simple: First, make sure you are in the correct directory before trying to use "ng serve".

gatzkerob avatar Feb 11 '18 19:02 gatzkerob

My solution is to delete my app folder and recreate using "ng new".

First time I created the app, the download of NPM modules was slow and I switched by networks - later I cancelled the ng new and re-ran it withouth cleaning the dirs. That caused the issue for me. So, deleting the app directory and re-creating the app solved my issue.

This was on Windows

srikanthps avatar Feb 17 '18 16:02 srikanthps

in my case there is a hidden file called .angular-cli.json just remove . from it name to be angular-cli.json

ahmedkamr avatar Feb 19 '18 14:02 ahmedkamr

This happened to me because I renamed the project/repo/everything, but forgot to rename the project name in .angular-cli.json. After I fixed it there, it worked just fine.

jonahbron avatar Feb 20 '18 19:02 jonahbron

Happened to me uploading a repo from windows to an online drive.

Made a new app and copped over the missing files.

developerndm avatar Feb 28 '18 15:02 developerndm

I had the same error when I tried to run ng test. The solution was easy. I was located in wrong directory. I had to cd one level deeper, where all my files were located.

PaloMiklo avatar Mar 06 '18 15:03 PaloMiklo

hello guys, I think this is the simple problem we are ignored: in this case, when I moved the project one directory to another directory there is some hidden file called like::::::".angular-cli ", ".editorconfig". show the hidden file in the old project and copy this file and past it in the new distention. this is solved the issue for me. or any other angular project or create a new project then copy the hidden file and past it in the new destination

piyarulps avatar Mar 19 '18 12:03 piyarulps

Same here. I copied to a new directory using cp -r command where it did not copy .angular-cli.json file which is a hidden file. if your machine is unix/mac then run this command on your source folder to find the .angular-cli.json . after copying to the destination folder it worked like charm. ls -ltr A command should show hidden files.

anandbabud1987 avatar Apr 10 '18 03:04 anandbabud1987

@anandbabud1987 Your solution worked for me. I really appreciate your way. Thanks a lot, mate

trungtruc1094 avatar May 10 '18 13:05 trungtruc1094

@HDaghash, Thanks! copying .angular-cli.json from an old project to the new worked perfect

montheryounis avatar Jun 02 '18 22:06 montheryounis

if you have this

_angular-cli.json

rename it to this

.angular-cli.json

blinks32 avatar Oct 13 '18 07:10 blinks32

The 'Cannot read property 'config' of null' was came after i did git checkout new branch. Please do once the 'npm install'. The error got cleared for me. Now I can do 'ng serve' normally. Thanks !

Ramaprasath avatar Nov 22 '18 08:11 Ramaprasath