TypeError: Cannot read property 'config' of null
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 --versionand 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.
I have .angular-cli.json in the same directory but still sudo npm run build gives me this error
@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.
Guys, quickest solution is to do this $ sudo rm -rf node_modules $ npm install $ ng serve
@HDaghash, Thanks! copying .angular-cli.json from an old project to the new worked!
This is a really bad error message.
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 someone cares about our problems.
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.
ng init did the job for me :)
init seems the right way
This issue is closed and is reproduced for 1/2 people who use angular-cli.
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.
you must have .angular-cli.json
it use my one day
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]
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 .
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
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.
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? ;)
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!
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 .