Angular-cli: Cannot destructure property `bold` of 'undefined' or 'null'

Created on 17 Jan 2018  路  6Comments  路  Source: angular/angular-cli

When using any angular cli commands it shows the below error:

D:\Core2\Angular5Core21\Angular5Core21>ng -v
D:\Core2\Angular5Core21\Angular5Core21\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. (D:\Core2\Angular5Core21\Angular5Core21\node_modules\@angular\cli\upgrade\version.js:12:39)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object. (D:\Core2\Angular5Core21\Angular5Core21\node_modules\@angular\cli\commands\build.js:4:19)
at Module._compile (module.js:660:30)

D:\Core2\Angular5Core21\Angular5Core21>ng g c nrm
D:\Core2\Angular5Core21\Angular5Core21\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. (D:\Core2\Angular5Core21\Angular5Core21\node_modules\@angular\cli\upgrade\version.js:12:39)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object. (D:\Core2\Angular5Core21\Angular5Core21\node_modules\@angular\cli\commands\build.js:4:19)
at Module._compile (module.js:660:30)

Most helpful comment

I resolved this issue by installing the 'chalk' dependency and 'angular-devkit/core' globally.

  1. npm -g install chalk
  2. npm -g install @angular-devkit/core

That resolved the issue for me.

All 6 comments

I have this same problem when running the following command:
ng --version

I just setup a new .NET Core Angular project, updated npm to the latest (5.6.0) and then installed '@angular/cli' using the following command:
npm install -g @angular/cli

When the above installation had errors, I ran the following commands:

  1. npm install -g --save-dev @angular/cli@latest
  2. npm install -g --save-dev @angular/[email protected]
  3. npm install --save-dev @angular/[email protected]

Still receiving the error.

I resolved this issue by installing the 'chalk' dependency and 'angular-devkit/core' globally.

  1. npm -g install chalk
  2. npm -g install @angular-devkit/core

That resolved the issue for me.

Also had to:
npm install @angular-devkit/core

The presented solution (adding the two packets with -g) does not help me the least :-/

With only latest version numbers in package.json I (still) get

> ng -v
C:\<MYPATH>\npm\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:\<MYPATH>\npm\node_modules\@angular\cli\upgrade\version.js:12:39)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\<MYPATH>\npm\node_modules\@angular\cli\bin\ng:9:17)
    at Module._compile (module.js:652:30)

I am using lerna, and have hoisted most everything. That causes ng build to fail with an arcane error message about not being able to deconstruct something. The solution was to omit @angular-devkit/* from hoisting (using lerna's nohoist option). Now why would that be necessary? Why would it matter if @angular-devkit/build-angular were a couple of levels higher in the node hierarchy?

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings