TypeError: Cannot destructure property `bold` of ‘undefined’ or ‘null’.

When you try to create new component using the following command

ng g c componentName --module=app.shared.module getting following errors

C:\Users\Asish\Source\Repos\MOLWeb\MOLWeb\MOLWeb\node_modules\@angular\cli\upgrade\version.js:12
const { bold, red, yellow } = chalk_1.default;
^

TypeError: Cannot destructure property `bold` of ‘undefined’ or ‘null’.
at Object.<anonymous> (C:\Users\Asish\Source\Repos\MOLWeb\MOLWeb\MOLWeb\node_modules\@angular\cli\upgrade\version.js:12:39)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object.<anonymous> (C:\Users\Asish\Source\Repos\MOLWeb\MOLWeb\MOLWeb\node_modules\@angular\cli\commands\build.js:4:19)
at Module._compile (internal/modules/cjs/loader.js:654:30)


Solution:- The issue raising because of the bug with the latest Angular CLI. The interim solution is to go back to Angular CLI 1.6.8 by 
executing the following commands.
 npm uninstall @angular/cli
 npm install @angular/[email protected]
 npm install --save-dev @angular/[email protected]

Add Comment