- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试将我的 Angular 2 项目从 2.0.0
升级到 2.4.1
。我知道自 2.0.0
版本以来已经采用了语义版本控制,2.x.x
版本应该是直接替换。我的经验似乎表明并非如此。也许我只是不知道自己在做什么,但我发现这并不简单......
我天真的第一种方法是手动更新我的 @angular
依赖项。您可以在下面引用我的 package.json(更新 1)。我进行了这些更改,然后执行了 npm install
并收到了几个警告,然后在我尝试执行 ng serve
时出现了以下错误。
Cannot read property 'AssetUrl' of undefined
还有我的警告...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.15: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN @angular/core@2.4.1 requires a peer of rxjs@^5.0.1 but none was installed.
npm WARN @angular/core@2.4.1 requires a peer of zone.js@^0.7.2 but none was installed.
npm WARN @angular/http@2.4.1 requires a peer of rxjs@^5.0.1 but none was installed.
npm WARN @angular/compiler-cli@0.6.4 requires a peer of @angular/compiler@2.0.2 but none was installed.
npm WARN @angular/compiler-cli@0.6.4 requires a peer of @angular/platform-server@2.0.2 but none was installed.
npm WARN @angular/compiler-cli@0.6.4 requires a peer of @angular/core@2.0.2 but none was installed.
npm WARN @ngtools/webpack@1.2.1 requires a peer of @angular/compiler-cli@^2.3.1 but none was installed.
npm WARN @ngtools/webpack@1.2.1 requires a peer of @angular/tsc-wrapped@^0.5.0 but none was installed.
npm WARN @ngtools/webpack@1.2.1 requires a peer of webpack@^2.1.0-beta.25 but none was installed.
所以我陷入了试图修复这些警告的困境,但我不知道如何修复所有警告(例如@ngtools/webpack),其中一些似乎相互冲突。所以我放弃了更新我的 angular 2 版本的手动方法......
原始包.json
{
"name": "frontend",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"build": "ng build",
"buildProd": "ng build --env=prod"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/material": "^2.0.0-alpha.9-experimental-pizza",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@types/google-libphonenumber": "^7.4.8",
"angular2-datatable": "^0.4.2",
"apollo-client": "^0.4.22",
"core-js": "^2.4.1",
"google-libphonenumber": "^2.0.4",
"graphql-tag": "^0.1.15",
"hammerjs": "^2.0.8",
"ng2-bootstrap": "^1.1.16",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.2",
"zone.js": "^0.6.26"
},
"devDependencies": {
"@types/hammerjs": "^2.0.33",
"@types/jasmine": "^2.2.30",
"@types/lodash": "^4.14.39",
"angular-cli": "1.0.0-beta.16",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.9",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2",
"typings": "1.4.0"
}
}
package.json 的更新 1
{
"name": "frontend",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"build": "ng build",
"buildProd": "ng build --env=prod"
},
"private": true,
"dependencies": {
"@angular/common": "2.4.1",
"@angular/compiler": "2.4.1",
"@angular/core": "2.4.1",
"@angular/forms": "2.4.1",
"@angular/http": "2.4.1",
"@angular/material": "^2.0.0-alpha.9-experimental-pizza",
"@angular/platform-browser": "2.4.1",
"@angular/platform-browser-dynamic": "2.4.1",
"@angular/router": "3.0.0",
"@types/google-libphonenumber": "^7.4.8",
"angular2-datatable": "^0.4.2",
"apollo-client": "^0.4.22",
"core-js": "^2.4.1",
"google-libphonenumber": "^2.0.4",
"graphql-tag": "^0.1.15",
"hammerjs": "^2.0.8",
"ng2-bootstrap": "^1.1.16",
"rxjs": "5.0.1",
"ts-helpers": "^1.1.2",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@types/hammerjs": "^2.0.33",
"@types/jasmine": "^2.2.30",
"@types/lodash": "^4.14.39",
"angular-cli": "1.0.0-beta.16",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.9",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2",
"typings": "1.4.0"
}
}
因为当我试图挑选我的 Angular 依赖项进行更新时,我最终陷入了其他需要更新的依赖项的蜘蛛网中,我接下来尝试只更新所有内容。
基于 this answer我尝试了以下方法:
npm i -g npm-check-updates
npm-check-updates -u
npm install
一切顺利,但是当我尝试 ng serve 时,出现以下错误:
ERROR in AppModule is not a NgModule
使用收集到的信息 here ,我降级了我的 typescript 版本,那个错误消失了,但弹出了一个新错误。
ERROR in Error encountered resolving symbol values statically. Reference to a non-exported function (position 29:10 in the original .ts file), resolving symbol restPaths in rest-paths.ts, resolving symbol AppModule in app.module.ts, resolving symbol AppModule in app.module.ts
我一直在努力解决这些错误,但事实上我遇到了这么多麻烦,这是一个危险信号。
有人可以帮忙吗?我是不是采取了错误的方法?
请注意,我看到了一些关于更新 angular-cli 项目的建议,这些建议建议卸载 angular-cli 并重新安装它,然后执行 ng init 并覆盖您的配置文件。这对我不起作用,因为我已经有了最新版本。
编辑:关于拥有最新的 angular-cli 的说法是不正确的。我有 angular-cli version 1.0.0-beta.16
而在这次编辑时最新版本是 1.0.0-beta.24
。尽管如此,我确实尝试更新我的 angular-cli 并在我现有的项目上运行 ng init 。我现在注意到我没有严格按照 angular-cli github 页面上概述的步骤进行操作。我跳过了 npm install --save-dev angular-cli@latest
,并放弃了我所有的 node_modules,而不是使用他们概述的 rm 命令。
最佳答案
USEFUL:
Use the official Angular Update Guide select your current version and the version you wish to upgrade to for the relevant upgrade guide. https://update.angular.io/
See GitHub repository Angular CLI diff for comparing Angular CLI changes. https://github.com/cexbrayat/angular-cli-diff/
2018 年 12 月 26 日更新:
使用官方Angular Update Guide在上面的有用部分中提到。它提供了最新信息以及指向升级期间可能有用的其他资源的链接。
2018 年 8 月 5 日更新:
Angular CLI 1.7 引入了ng update
。
ng update
A new Angular CLI command to help simplify keeping your projects up to date with the latest versions. Packages can define logic which will be applied to your projects to ensure usage of latest features as well as making changes to reduce or eliminate the impact related to breaking changes.
Configuration information for ng update can be found here
1.7 到 6 更新
CLI 1.7 不支持自动 v6 更新。通过你的包管理器手动安装@angular/cli,然后运行更新迁移示意图来完成这个过程。
npm install @angular/cli@^6.0.0
ng update @angular/cli --migrate-only --from=1
2017 年 4 月 30 日更新:
1.0 更新
您现在应该关注 Angular CLI migration guide
2017 年 4 月 3 日更新:
RC 更新
您应该遵循 Angular CLI RC migration guide
2017 年 2 月更新:
请注意 1.0.0-beta.32 有重大更改并删除了 ng init 和 ng update
拉取请求 here陈述如下:
BREAKING CHANGE: Removing the ng init & ng update commands because their current implementation causes more problems than it solves. Update functionality will return to the CLI, until then manual updates of applications will need done.
angular-cli CHANGELOG.md陈述如下:
BREAKING CHANGES - @angular/cli: Removing the ng init & ng update commands because their current implementation causes more problems than it solves. Once RC is released, we won't need to use those to update anymore as the step will be as simple as installing the latest version of the CLI.
2017 年 2 月 17 日更新:
Angular-cli 现已添加到 NPM @angular 包中。您现在应该用以下命令替换上面的命令 -
全局包:
npm uninstall -g angular-cli @angular/cli
npm cache clean
npm install -g @angular/cli@latest
本地项目包:
rm -rf node_modules dist # On Windows use rmdir /s /q node_modules dist
npm install --save-dev @angular/cli@latest
npm install
ng init
原始答案
您应该按照 README.md 中的步骤进行操作在 GitHub 上通过 angular-cli 更新 Angular .
他们在这里:
更新 angular-cli
要将 angular-cli 更新到新版本,您必须同时更新全局包和项目的本地包。
全局包:
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@latest
本地项目包:
rm -rf node_modules dist tmp # On Windows use rmdir /s /q node_modules dist tmp
npm install --save-dev angular-cli@latest
npm install
ng init
运行 ng init
将检查由 ng new 创建的所有自动生成的文件中的更改,并允许您更新您的文件。对于每个更改的文件,您有四种选择:y(覆盖)、n(不覆盖)、d(显示您的文件和更新后的文件之间的差异)和 h(帮助)。
仔细阅读每个代码文件的差异,然后接受更改或在 ng init 完成后手动合并它们。
关于angular - 如何升级 Angular CLI 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41403810/
我在全局范围内安装了最新的 angular-cli,并且我的项目正在成功构建。 在阅读另一个问题的建议解决方案时,(https://github.com/angular/angular-cli/iss
根据official docs关于 .angular-cli.json 配置文件,仅支持 main、test、polyfills 作为 webpack 入口文件。 如何通过定义 .angular-cl
我想在s3存储桶中搜索文件名abc.zip,并且有将近60个存储桶,每个存储桶都有2到3个级别的子目录或文件夹。我尝试使用AWS CLI命令执行搜索,以下是我尝试过的命令,但即使文件存在于存储桶中,也
我正在尝试在 C++/CLI 中查找赋值运算符和复制构造函数的示例。我在 Google 上花了很多时间,但令人惊讶的是我找不到一个看起来很常见的例子。 最佳答案 .NET 语义没有复制构造函数或赋值运
我需要获取另一个窗口的句柄。 这是它的代码: private: System::Void btn_find_Click(System::Object^ sender, System::EventAr
有点好奇实际上有多少人使用 C++/CLI?那么有多少人在使用它呢?人们是否只在托管环境下寻找程序员的特定工作?围绕 c++/cli 的社区有多大?从我目前看到的情况来看,有不少语法变化,作为 C++
我正在阅读一些 C++/CLI Material ,并且遇到了文字字段的概念: literal int inchesPerFoot = 12; 这是否比 const 更可取,因为 const FIEL
通过 npm install -g angular-cli@latest 安装 Angular CLI (angular-cli@1.0.0-beta.16) 失败,出现以下错误 npm-debug.
我正在尝试在我的 Ember CLI 应用程序中配置适配器以根据环境使用不同的主机。在开发中,我希望它是默认的当前主机(让我通过 --proxy 选项自定义它,但在生产中我知道它将是 http://s
我最近开始使用 Angular/CLI 工具,我在执行文件时遇到了一个问题,那就是我运行时 ng serve 那么这个命令可以帮助我们在源文件中进行任何更改时自动重新加载站点,但在我的系统中它没有发生
是否有推荐的方法通过 c++ cli 包装 native c++ 库? 最佳答案 不确定是否一种尺寸适合所有人,但是,是的,这很大程度上是一个机械过程。您的 ref 类包装器应该声明一个私有(priv
我有一个关于为要在 C# 中使用的 native C++ 类创建 C++ CLI 包装器的问题。 这是一个示例代码: #include "stdafx.h" #pragma once using na
下面的代码打印 0 和 3。这是代码生成错误吗?我在 .NET 4.0 下使用 Visual Studio 2012 Update 3 RC 运行它 #include "stdafx.h" using
它是如何工作的?它是否有不同的部分 - 有些方法是托管的,有些是非托管的,它是否将每个方法都转换为托管的,试图保持所有东西都处于托管状态并在必须时进行互操作调用? 最佳答案 三种不同的compiler
如果我没记错的话,函数必须是 CLR 世界中类的成员,而全局函数在 C++/CLI 中是可能的。这是否意味着这些全局函数是某种隐藏的“全局”类的一部分?如果是这样,出于反射目的,人们将如何获取其类型?
如何在 Angular 中重建我的项目。我首先使用 ng build 构建它,但无法再次执行该命令,因为它不会让我更改文件夹。 我收到此错误消息: EPERM:不允许操作,lstat 是否有另一个命令
我遇到了两个相互引用的类的问题。我曾尝试使用接口(interface)来解决问题,但遇到了其他问题,例如类重新定义。我只是不确定如何正确执行此操作。 这是我正在做的事情的一个例子。注意:我已经去掉了所
我是 React.js 的新手,我正在尝试从 tutorialspoint 上的教程中学习但我遇到了错误。这是我执行 npm start 命令时控制台上的错误: C:\Users\HP\Desktop
我正在尝试将我的 angular cli 和 angular core 从 12 升级到 13,但看起来存在对等依赖性问题。有人遇到过这个问题吗? npx @angular/cli@13 update
我正在我的 ubuntu 上安装 influxdb_2.0.9,我按照这里的说明操作: https://docs.influxdata.com/influxdb/v2.0/install/?t=Lin
我是一名优秀的程序员,十分优秀!