2

I am trying to import BrowserAnimationsModule for my angular 4 project with the import line as follows

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

enter image description here

I have added the animations module in the project folder with the command

npm install --save @angular/animations

But when I see the node_modules folder, and then platform-browser folder, I don't see any animations folder which I guess is the reason I am getting the error for BrowserAnimationsModule.

So may I know how do I import BrowserAnimationsModule in my case?

Error I get while doing ng serve

enter image description here

angularrocks.com
  • 26,767
  • 13
  • 87
  • 104
Kiran Dash
  • 4,816
  • 12
  • 53
  • 84
  • Have you tried to restart your IDE? Do you have any errors when running `ng serve` ? – angularrocks.com Aug 06 '17 at 08:37
  • Yes. ng serve throws error. I have added a screenshot now. And yes restarting my IDE also shows the same error. I think may be the animation folder is not present. So that might be a case. I am not entirely sure though. – Kiran Dash Aug 06 '17 at 09:14
  • 1
    that is wired. i just installed the `@agnular/animations` in to the new created project and all good. What is your output of `ng -v` ? Seams you running pretty old cli version as I can tell by looking in to second printscrin. – angularrocks.com Aug 06 '17 at 10:09

1 Answers1

1

Seams like you are using outdated cli that already has being deprecated. Try:

npm uninstall angular-cli -g
npm cache clean
npm install @angular/cli -g

Also make sure the you are running Node version >= 6.9 and latest npm

If you need to migrate your existing app checkout this answer and this doc otherwise by installing latest @angular/cli you should be fine.

angularrocks.com
  • 26,767
  • 13
  • 87
  • 104
  • Thanks. I am sure now that is the issue. I did uninstall and reinstall it. Now the angular cli and node is updated. And now I created a new project and it has animations folder inside of platform-browser. But my existing project configuration had older configuration so still getting errors there. I will check online and try to update the configuration files and see if that fixes everything. Have a good day – Kiran Dash Aug 06 '17 at 14:11
  • My problem is solved. But It would really help me if you can guide me providing a URL or something which can guide me on how to change the configuration files for a project after updating angular cli and node js. – Kiran Dash Aug 06 '17 at 14:14
  • ok, but that leads to another problem, I guess one like Kiran Dash is having. Running last command gives latest version of angular-cli (version 7) which makes use of `angular.json` which is somehow different than old versions of Angular where filename is `.angular-cli.json`. What if someone is using angular 2 in his/her project? – Sudhir Kaushik Dec 15 '18 at 10:39