0
votes

I'm trying to add a new component in Asp.Net Core 2.0 SPAs using angular-cli. I added dev dependencies in the project's root folder using

npm install --save-dev @angular/cli@latest

angular-cli version

Angular CLI: 1.7.1; Node: 8.9.4; OS: win32 x64

But when i write ng g c ComponentName this error occurs

C:\Users\USERNAME\source\repos\MyApp\MyApp\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. (C:\Users\USERNAME\source\repos\MyApp\MyApp\node_modules\@angular\cli\upgrade\version.js:12:39) at Module._compile (module.js:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3) at Module.require (module.js:587:17) at require (internal/module.js:11:18) at Object. (C:\Users\USERNAME\source\repos\MyApp\MyApp\node_modules\@angular\cli\commands\build.js:4:19) at Module._compile (module.js:643:30)

I saw this solution but none of them worked for me. How to resolve this issue?

Thanks

enter image description here

1
Have you tried deleting package-lock.json or yarn.lock and the node_modules and reinstalling them? - Arjun Panicker
There are no such folders by that names ... - Kamran Arshad
Just delete lock.json files and node_modules as suggested by @ArjunPanicker and re-install node_modules. - planet_hunter
Try taking your cli version back to 1.5.x - yash_DedSec
Go to ur project's root folder and delete the files named - package-lock.json, yarn.lock(if exists) and delete the folder called node_modules. Then do npm install again in the root folder of the project. - Arjun Panicker

1 Answers

1
votes

Do this.

npm uninstall @angular/cli
npm install @angular/[email protected]

Then try again generating your component

Another Solution

As i can see that your animation module is on Angular 4

If above method does not work change the version of the angular/cli to 1.4.10

npm uninstall @angular/cli
npm install @angular/[email protected]

Hope it helps!