找不到模块“@angular/platform-b​​rowser/animations" [英] Cannot find module '@angular/platform-browser/animations'

查看:18
本文介绍了找不到模块“@angular/platform-b​​rowser/animations"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到[ts] 找不到模块‘@angular/platform-b​​rowser/animations’的错误."

I get the error of "[ts] Cannot find module '@angular/platform-browser/animations'."

我已经安装了以下内容:

I have installed the following:

  1. npm install --save @angular/material @angular/cdk
  2. npm install --save @angular/animations

并尝试在 app.module 中导入 BrowserAnimationsModule,如下所示:"从'@angular/platform-b​​rowser/animations'导入{ BrowserAnimationsModule };"

and try to import the BrowserAnimationsModule in the app.module like so: "import { BrowserAnimationsModule } from '@angular/platform-browser/animations';"

这是在我的 package.json 中

This is in my package.json

"dependencies": {
    "@agm/core": "^1.0.0-beta.0",
    "@angular/animations": "^7.0.1",
    "@angular/cdk": "^7.0.2",
    "@angular/common": "^2.4.0",
    "@angular/compiler": "^2.4.0",
    "@angular/core": "^2.4.0",
    "@angular/forms": "^2.4.0",
    "@angular/http": "^2.4.0",
    "@angular/material": "^7.0.2",
    "@angular/platform-browser": "^2.4.0",
    "@angular/platform-browser-dynamic": "^2.4.0",
    "@angular/router": "^3.4.0",
    "animate.css": "^3.5.2",
    "arrive": "^2.3.1",
    "bootstrap": "^3.3.5",
    "bootstrap-notify": "^3.1.3",
    "bootstrap-select": "^1.12.2",
    "bootstrap-tagsinput": "^0.7.1",
    "chartist": "^0.9.4",
    "chartist-plugin-zoom": "^0.4.0",
    "chartjs-plugin-zoom": "^0.5.0",
    "core-js": "^2.4.1",
    "datatables": "1.10.12",
    "datatables.net-bs": "1.10.12",
    "datatables.net-responsive": "^2.1.1",
    "domready": "^1.0.8",
    "eonasdan-bootstrap-datetimepicker": "4.17.47",
    "fullcalendar": "^3.4.0",
    "googleapis": "^19.0.0",
    "jasny-bootstrap": "^3.1.3",
    "jquery": "^1.12.4",
    "nouislider": "^9.2.0",
    "rxjs": "^5.1.0",
    "twitter-bootstrap-wizard": "^1.2.0",
    "validate": "^3.0.1",
    "web-animations-js": "^2.2.2",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0",
    "@angular/compiler-cli": "^2.4.0",
    "@types/bootstrap": "^3.3.32",
    "@types/chartist": "^0.9.34",
    "@types/jasmine": "2.5.38",
    "@types/jquery": "^1.10.31",
    "@types/node": "^6.0.73",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.0.0"
  }

你能告诉我如何纠正这个问题吗?谢谢.

Can you please show me how to correct this? Thank you.

推荐答案

在我看来,您正在尝试使用最新版本的 Angular Material 和非常过时的 Angular 版本.

It seems to me that you're trying to use the latest version of Angular Material with extremely outdated versions of Angular.

我建议您要么坚持使用 2.x.x 版本的 Angular Material 和 Angular CDK,要么按照以下步骤操作:

I suggest that you either stick to the 2.x.x versions of Angular Material and Angular CDK or that you follow the steps below:

注意 #1:除非明确说明,否则所有命令都应在项目的根目录中运行.

Note #1: All commands should be run in the root of your project unless explicitly stated.

注意 #2:请不要复制命令中的注释(也就是 # 符号及其后的文本).它们用于解释命令的作用.

Note #2: Please don't copy the comments (aka the # symbol and the text after it) in commands. They are there for explaining what the command does.

  1. 通过运行以下命令重新安装 Angular CLI 以安装最新版本:

  1. Reinstall the Angular CLI in order to install the latest version by running the following commands:

npm i -g @angular/cli # Globally installs the Angular CLI
npm i @angular/cli # Locally installs the Angular CLI (to your project)

  • 通过运行以下命令将您的 Angular 项目文件更新为新的 Angular CLI v6+ 工作区文件:

  • Update your Angular project file to the new Angular CLI v6+ workspace file by running the following command:

    ng update @angular/cli
    

  • 通过运行以下命令安装最新版本的 TypeScript (v3.1.1):

    npm i -D typescript@latest
    

    这是 Angular v7 及更高版本所必需的.

    This is required for Angular v7 and up.

    通过运行以下命令将所有 Angular 依赖项更新到 Angular v7+:

    Update all of your Angular dependencies to Angular v7+ by running the following command:

    ng update @angular/core
    

  • 应该(希望)就是这样!如果您需要任何说明,请随时发表评论!

    That should (hopefully) be it! If you need any clarifications, don't hesitate to leave a comment!

    注意:以上说明改编自官方Angular 更新指南.

    Note: The instructions above are adapted from the official Angular Update Guide.

    这篇关于找不到模块“@angular/platform-b​​rowser/animations"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆