Angular 2 Router Animation - 找不到模块“@angular/platform-b​​rowser/animations”

2023-12-23

我一直在关注 Angular 2 路由和导航示例,可以在此链接中找到:https://plnkr.co/edit/I4ArEQTniO7MJtfzpBWl?p=info https://plnkr.co/edit/I4ArEQTniO7MJtfzpBWl?p=info.

当我运行转译器时,收到错误消息:“client/app/app.module.ts(5,41): error TS2307: Cannot find module '@angular/platform-b​​rowser/animations'。”

根据我的 systemjs.config.js (如下所示),我希望模块“@angular/platform-b​​rowser/animations”是文件“platform-b​​rowser-animations.umd.js”,位于 node_modules/@angular /platform-b​​rowser/bundles,但它不在那里。

//systemjs.config.js
(function (global) {
  System.config({
    paths: {
  // paths serve as alias
  'npm:': 'node_modules/'
   },
  // map tells the System loader where to look for things
  map: {
  // our app is within the app folder
  app: 'app',

  '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
  '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
  '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
  '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
  '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
  '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
  '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
  '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
  '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
  '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
  '@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
  '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
  '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
  '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',

  // other libraries
  'rxjs':                      'npm:rxjs',
  'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
  //app: {
  //  main: './main.js',
  //  defaultExtension: 'js'
  //},
  client: {
    main: './main.js',
    defaultExtension: 'js'
  },
  rxjs: {
    defaultExtension: 'js'
  }
}
});
})(this);

使用 npm 我尝试安装缺少的框架,但收到未满足的依赖项错误消息:

+-- UNMET PEER DEPENDENCY @angular/[email protected] /cdn-cgi/l/email-protection
+-- UNMET PEER DEPENDENCY @angular/[email protected] /cdn-cgi/l/email-protection
`-- UNMET PEER DEPENDENCY @angular/[email protected] /cdn-cgi/l/email-protection

然后,我尝试安装依赖版本,但继续收到未满足的依赖项消息。

>npm install @angular/[email protected] /cdn-cgi/l/email-protection @angular/[email protected] /cdn-cgi/l/email-protection @angular/[email protected] /cdn-cgi/l/email-protection --save 

我注意到一条警告表明我应该安装 Angular 4。

npm WARN @angular/[email protected] /cdn-cgi/l/email-protection requires a peer of @angular/[email protected] /cdn-cgi/l/email-protection but no
ne was installed.

看起来我已经安装了动画 4.0,但它需要核心 4.0,但我不想安装。我是否需要卸载动画 4.0 并安装早期版本的动画?我的 package.json 文件如下。

//package.json
{
"name": "angular-quickstart",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"build": "tsc -p client/",
"build:watch": "tsc -p client/ -w",
"build:e2e": "tsc -p e2e/",
"serve:e2e": "lite-server -c=bs-config.e2e.json",
"prestart": "npm run build",
"start": "npm run build:watch",
"pree2e": "npm run build:e2e",
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
"preprotractor": "webdriver-manager update",
"protractor": "protractor protractor.config.js",
"pretest": "npm run build",
"test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
"pretest:once": "npm run build",
"test:once": "karma start karma.conf.js --single-run",
"lint": "tslint ./client/**/*.ts -t verbose"
  },
 "keywords": [], 
"author": "",
"license": "MIT",
"dependencies": {
"@angular/animations": "^4.0.0",
"@angular/common": "^2.4.8",
"@angular/compiler": "~2.4.0",
"@angular/core": "^2.4.8",
"@angular/forms": "~2.4.0",
"@angular/http": "~2.4.0",
"@angular/platform-browser": "^2.4.10",
"@angular/platform-browser-dynamic": "~2.4.0",
"@angular/router": "~3.4.0",
"angular-animate": "^1.6.3",
"angular-in-memory-web-api": "~0.2.4",
"body-parser": "^1.17.0",
"bootstrap": "^3.3.7",
"cookie-parser": "^1.4.3",
"core-js": "^2.4.1",
"ejs": "^2.5.6",
"express": "^4.15.0",
"express-session": "^1.15.1",
"jade": "^1.11.0",
"jquery": "^3.1.1",
"mongoose": "^4.8.5",
"morgan": "^1.8.1",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"rxjs": "5.0.1",
"stylus": "^0.54.5",
"systemjs": "0.19.40",
"toastr": "^2.1.2",
"zone.js": "^0.7.4"
 },
"devDependencies": {
"concurrently": "^3.2.0",
"lite-server": "^2.2.2",
"typescript": "~2.0.10",
"canonical-path": "0.0.2",
"tslint": "^3.15.1",
"lodash": "^4.16.4",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"@types/node": "^6.0.46",
"@types/jasmine": "2.5.36"
 },
"repository": {}
}

看来问题可能与我的动画版本有关?如果您同意,如何卸载现有版本以及我应该安装哪个版本与我拥有的 @angular/core 版本 2.4.8 兼容。如果这不是问题,如何安装丢失的文件 @angular/platform-b​​rowser/bundles/platform-b​​rowser-animations.umd.js?


经过几个小时的研究后,我找不到与我的 @angular/core 版本(范围为 2.4.0-2.4.8)兼容的 @angular/animations 版本。我读了这篇文章的答案,如何获取兼容 Angular 2 模块的版本列表? https://stackoverflow.com/questions/41324650/how-to-get-list-of-versions-for-compatible-angular-2-modules。这篇文章表明,除了路由器之外,Angular 2 的所有模块都处于同一版本,因此我将 @Angular/animations 2.4.8 插入我的 package.json 并将所有版本更改为 2.4.8,包括我想确定的动画条目我并没有遗漏什么。然后我运行 npm install ,但在动画版本上失败了。

我终于找到了这篇文章;http://angularjs.blogspot.com/ http://angularjs.blogspot.com/关于更新到 Angular 4.0。这篇文章还特别提到了我一直缺少的动画模块,但只有升级后才可用。我按照 Windows 的简单更新说明进行操作,我的应用程序现在运行良好。我的应用程序与指南中的 plunker 示例非常相似。根据这篇文章,如果您运行的是 Angular 2.x.x,那么这应该向后兼容大多数应用程序。以下是升级说明。

更新至4.0.0

更新到 4 就像将 Angular 依赖项更新到最新版本一样简单,并仔细检查是否需要动画。这适用于大多数用例。

在 Linux/Mac 上:

npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-b​​rowser,platform-b​​rowser-dynamic,platform-server,router,animations}@latest typescript@latest --save

在 Windows 上:

npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-b​​rowser@latest @angular /platform-b​​rowser-dynamic@latest @Angular/platform-server@latest @Angular/router@latest @Angular/animations@latest typescript@latest --save

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Angular 2 Router Animation - 找不到模块“@angular/platform-b​​rowser/animations” 的相关文章

  • 向 JS 计算器添加键盘支持时出现的问题

    我想为我的计算器添加键盘支持 当我用键盘按下操作 即 或 时 js将其视为数字 而不是操作 例如 当我通过点击计算 10 11 时 我将得到 21 作为结果 当我通过键盘输入时 我会得到 10 为什么会发生这种情况 是否可以改变它 div
  • Webpack 和 Angular HTML 图像加载

    我一直对 webpack 和 Angular 感到头疼 这可能有一个简单的答案 但我无法弄清楚 我已经阅读了堆栈溢出中关于这个主题的几乎所有答案 但都无济于事 我有一个像这样的 html 页面 还有其他包含图像的模板 img
  • $http.get() 与 JSON 数据

    我正在编写一个服务器应用程序 并希望客户端使用正文中的数据来参数化我的 GET 方法 如下所示 http v GET http localhost 3000 url text 123 foo bar GET url HTTP 1 1 Acc
  • Disqus 评论数始终为 0 条评论

    我想我已经按照通用代码的说明设置了 Disqus 问题是它总是说某个帖子有 0 条评论 拿这个帖子来说 http tx0rx0 com retropie and the raspberry pi http tx0rx0 com retrop
  • RequireJS 文本插件和变量连接字符串

    我正在使用 RequireJS 文本插件来加载一些 html 模板 当我将字符串文字传递给 require 函数时 它工作正常 var templateHTML require text templates template name ht
  • SVG 中三角形的圆角

    我正在尝试制作一个具有圆角的三角形 三角形将如下所示 左下角是唯一看起来相当容易制作的角 主要是因为这是一个 90 度的 转弯 该转弯是使用QSVG 中的命令具有以下参数 Q x y height x y height RADIUS从我正在
  • 禁用整个站点的 IE8 加速器

    是的 我知道有类似的问题 https stackoverflow com questions 499565 is it possible to disable ie8 accelerators on my website在 SO 上 但它已
  • Javascript:通过将路径作为字符串传递给对象来获取对象的深层值[重复]

    这个问题在这里已经有答案了 可能的重复 使用字符串键访问嵌套的 JavaScript 对象 https stackoverflow com questions 6491463 accessing nested javascript obje
  • Angular 1.6 和多个模块:在模块和组件之间共享全局变量

    我正在使用 Angular 1 6 7 我在我的应用程序中创建了多个模块 如何将父模块 myApp 中定义的常量 例如 rootURL 传递给子模块 childApp 更具体地说 我需要将 rootURL 的值分配给 childApp 组件
  • 大型应用的回流/布局性能

    我正在使用 GWT 构建一个 HTML 应用程序 其性能总体上是正确的 有时 它会加载 DOM 中的许多对象 并且应用程序会变得很慢 我使用 Chrome 开发者工具分析器来查看时间花在哪里 在 Chrome 下 一旦应用程序被编译 即没有
  • 如何上传文件 - sails.js

    我可以下载图像和 pdf 但无法下载文档文件 doc pptx odt 下载文档 doc pptx odt 时 仅将其下载为 ZIP XML 文件 我可以做什么 我在用着 填写上传文件文档 https github com balderda
  • javascript/jquery 禁用点击提交按钮,防止重复提交

    所以我的提交按钮如下所示 a href img src images user create product png border 0 a 当我双击它时 显然会双重提交 问题是 我将信息保存在数据库中 因此那里会有重复的信息 我不想那样 这
  • 使用 Socket.IO 时如何访问会话标识符?

    我有一个聊天 我需要管理独特的连接 我四处搜寻 但我找到的解决方案似乎都已被弃用 那么 如何使用 Socket IO 获取套接字的会话 ID 我在用着Node js http en wikipedia org wiki Node js Ex
  • 将占位符绑定到模型会导致 ng-change 在 IE 中加载时执行

    使用 angularjs 如果我将输入的占位符绑定到其模型 则当文档在 IE 中加载时会触发更改事件 这似乎不正确 我在其他浏览器中没有看到这种行为 JSFiddle http jsfiddle net VxBNW 6 Html div d
  • d3力定向布局-链接距离优先

    在 d3 中使用力导向布局 如何使链接距离成为优先事项 同时仍然保持良好的图形布局 如果我指定动态链接距离 但保留默认费用 则我的图形距离会因费用函数而发生一些变形 并且不再是准确的距离 但是 如果我删除电荷 图表将如下所示 任何建议表示赞
  • 在多个数组中搜索字符串,然后设置 var - jQuery

    我正在寻找基于字符串存在于哪个数组中设置一个变量 例如 var primary red blue yellow var secondary orange purple green 然后检查 purple 并返回它在 secondary 数组
  • 简单的颜色变化

    我正在创建一个用户界面 用户可以在其中更改页面的颜色值 我想要的是获取分配给其背景颜色的值并将其变亮一定程度 我只是想获得一条亮点线 而不必每次都制作新图像 示例 用户将背景颜色设置为 ECECEC 现在我希望某个元素边框变成 F4F4F4
  • 当选项卡重新加载(chrome 扩展)时,如何运行此脚本?

    所以我想在指定 URL 中重新加载选项卡时运行脚本 它几乎可以工作 但实际上 id 不能 这是我的清单文件 manifest version 2 name Sample Extension description Sample Chrome
  • 获取 byte[]

    我有一个 html 画布 如下所示 output is a base64string of image data var oldImage new Image oldImage onload function var resizeRatio
  • 使用 div 或表格来包含链接列更好吗?

    我的页面底部有 3 列链接 每列都放入一个 div 中 所有三个 div 都包装在页面中央的一个大 div 中 这是更适合桌子的东西还是桌子不适合这项工作 您还可以使用 ul http www w3schools com tags tag

随机推荐