Cannot find module angular/animations

前端 未结 6 1260
梦如初夏
梦如初夏 2021-02-12 01:44

I am using webpack in angular2 and when i try to run my app i get an error stating

Cannot find module \"@angular/animations\"

6条回答
  •  渐次进展
    2021-02-12 02:14

    You are on the right track, but just close! You can see in this discussion here, that animations was taken out of the core. Furthermore, hyphenated names are apparently being done away with - so angular animations is now @angular/animations, just as @angular/angular-cli has become @angular/cli.

    So, in order to (hopefully) resolve your issue - you should do the following:

    Update to Angular 4 in your project. You will need to run the following in order to do so: npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router,animations}@latest --save and you also need to update Typescript with npm install typescript@latest --save

    That should do the trick.

    If it does not do the trick, I would suggest checking your json package and making sure you bumped up to 4.0 in all the core aspects along with the now separate animations segment. Then, delete your node modules folder, clear your cache, and run a clean install with the update package, like so:

    >$  rm -rf node_modules
    >$  npm cache clear
    >$  npm install
    

    It is a little hectic right now with a lot of different people contributing a lot of changes and fixes to the core feature set, and then other parts of Angular being caught up with the core, so I would advise moving forward carefully with any project you are on, in very methodical steps, so that you can address issues that come up one by one (and easier to find/fix).

    Hope this helps!

提交回复
热议问题