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

I have .angular-cli.json in the same directory but still sudo npm run build gives me this error

ishandutta2007 avatar May 08 '17 23:05 ishandutta2007

@HDaghash, it works for me!! thanks. In my case I have created it, with ng new, but I don't want another directory into root directory, then I have moved the generated code, to my project root, and I forgot mentioned file.

lflores avatar May 10 '17 21:05 lflores

Guys, quickest solution is to do this $ sudo rm -rf node_modules $ npm install $ ng serve

justfathi avatar May 15 '17 12:05 justfathi

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

pshisbey avatar Jun 04 '17 19:06 pshisbey

This is a really bad error message.

ghost avatar Jun 06 '17 21:06 ghost

Copying the .angular-cli.json worked (fine)... But it could't be the plan that I have to copying this file when I create a new project...!

luigitonno avatar Jun 11 '17 22:06 luigitonno

@luigitonno someone cares about our problems.

ghost avatar Jun 11 '17 22:06 ghost

We had a similar problem and it was because of the fact that we deleted all the hidden files, guess config file also got deleted and hence the error.

abhalve avatar Jun 19 '17 10:06 abhalve

ng init did the job for me :)

peasandpetals avatar Jun 23 '17 07:06 peasandpetals

init seems the right way

abhalve avatar Jun 26 '17 04:06 abhalve

This issue is closed and is reproduced for 1/2 people who use angular-cli.

gtzinos avatar Jun 26 '17 14:06 gtzinos

I know how to resolve this issue. At the time of moving files from one folder to another, there is a hidden file .angular-cli.json. paste it into new folder. It works for me.

rekhasinghal08 avatar Jul 06 '17 07:07 rekhasinghal08

you must have .angular-cli.json it use my one day

TimeIsGoOn avatar Jul 13 '17 08:07 TimeIsGoOn

Looks like an usage problem of almost of app(skeleton) generators.... I believe a simple option to set directory to create the app should solve this issue... something like ng new app-name [dir-name]

brucepc avatar Jul 31 '17 14:07 brucepc

If you are using MAC-OS , you can enter defaults write com.apple.finder AppleShowAllFiles TRUE;\killall Finder in your terminal for showing the hidden files .

karocksjoelee avatar Aug 15 '17 09:08 karocksjoelee

I already had an existing application I wanted to start using angular-cli in. When trying to implement angular-cli for an existing application, for me, just doing npm install -g @angular/cli and then trying to use the ng commands did not work. After installing angular-cli I did the following. In a command line, in windows, I went to my C:\ folder and ran the command ng new foo. After nicely scaffolding my app, I copied the necessary files from this new folder and started moving them to my existing app folder and started sorting out the issues until I got my app running fine using angular-cli. This is the solution that worked for me when trying to implement angular-cli for an already existing application. Hope it helps

yosiasz avatar Aug 16 '17 16:08 yosiasz

it's happened to me several times. All of them, the problem was I had moved the project to different folders, and I did it through files/finder/explorer, so some hidden files weren't copied. try removing the new project, and copying it with the command line. worked awesome for me.

fmmajd avatar Sep 19 '17 08:09 fmmajd

Well, did anyone in this thread mentioned it is because .angular-cli.json is a hidden file and it is lost when you move your project to another folder? Did anyone or it is just me first? ;)

artuska avatar Sep 22 '17 16:09 artuska

SOLUTION: Na pasta do projeto deve conter um arquivo chamado: .angular-cli.json

PS: Caso tenha sido trocado a pasta do projeto para outro local sem ser exibido os arquivos ocultos, este arquivo acaba por não ser copiado junto com o projeto, ocasionando o erro!

adilsonmenezes avatar Oct 13 '17 16:10 adilsonmenezes

i found the solution ! :D in my case i moved the project to another directory there is a hidden file called .angular-cli show the hidden file in the old project and copy this file and paste it in the new distention . this is solved the issue for me .

felixivance avatar Oct 16 '17 21:10 felixivance