更新至Angular 5

如何更新到Angular 5?
这是my package.json中的内容:

“依赖项”:{
“@angular/animations”:“5.0.0”,
“@angular/common”:“5.0.0”,
“@angular/compiler”:“5.0.0”,
“@angular/core”:“5.0.0”,
“@angular/forms”:“5.0.0”,
“@angular/http”:“5.0.0”,
“@angular/platform浏览器”:“5.0.0”,
“@angular/platform browser dynamic”:“5.0.0”,
“@angular/router”:“5.0.0”,
“@types/jwt decode”:“^2.2.1”,
“引导”:“^3.3.7”,
“引导式sass”:“^3.3.7”,
“classlist.js”:“^1.1.20150312”,
“核心js”:“^2.4.1”,
“intl”:“^1.2.5”,
“jquery”:“^3.2.1”,
“jwt解码”:“^2.2.0”,
“rxjs”:“^5.4.2”,
“zone.js”:“^0.8.14”
},
“依赖性”:{
“@angular/cli”:“1.4.0-rc.2”,
“@angular/compiler cli”:“5.0.0”,
“@angular/language service”:“5.0.0”,
“@types/jasmine”:“~2.5.53”,
“@types/jasminewd2”:“~2.0.2”,
“@types/node”:“~6.0.60”,
“角度ide”:“^0.9.31”,
“codelyzer”:“~3.1.1”,
“茉莉花芯”:“~2.6.2”,
“jasmine spec reporter”:“~4.1.0”,
“因果报应”:“~1.7.0”,
“卡玛铬发射器”:“~2.1.1”,
“karma cli”:“~1.0.1”,
“因果报应报道伊斯坦布尔记者”:“^1.2.1”,
“因果报应茉莉”:“~1.1.0”,
“karma jasmine html reporter”:“^0.2.2”,
“节点sass”:“^4.5.3”,
“量角器”:“~5.1.2”,
“原始加载程序”:“^0.5.1”,
“sass加载程序”:“^6.0.6”,
“sw precache”:“^5.2.0”,
“ts节点”:“~3.2.0”,
“tslint”:“~5.3.2”,
“类型脚本”:“~2.3.3”
}

运行npm安装时出现此错误

npm错误!Windows\u NT 6.1.7601 npm错误!argv“C:\Program
Files\nodejs\node.exe“C:\Program
Files\nodejs\node\u modules\npm\bin\npm cli.js“install”npm ERR!
节点v6.11.2 npm错误!npm v3.10.10 npm错误!代码

npm错误!NotTarget未找到兼容版本:@angular/[email protected]
npm错误!notarget有效的安装目标:npm ERR!非目标5.0.0-rc.0,
5.0.0-beta.7,5.0.0-beta.6,5.0.0-beta.5,5.0.0-beta.4,5.0.0-beta.3,5.0.0-beta.2,5.0.0-beta.1,5.0-beta.0,4.4.3,4.4.2,
4.4.1、4.4.0-RC.0、4.3.6、4.3.5、4.3.4、4.3.3、4.3.2、4.3.1、4.3.0、4.3.0-RC.0、4.3.0-beta.1、4.3.0-beta.0、4.2.6、4.2.5、4.2.4、4.2.3、4.2.2、4.2.1、4.2.0、4.2.2。4.2.0-beta.1、4.2.0-4.2.0-1、4.2.0-1、4.2.0-1、4.2.0-beta.0、4.1.0-0、4.1.1.3、4.1.1.2、4.1.1.2.0-0-1、4.2.0-1、4.0-0-0-0-beta.0、4.0、4.1.1.0、4.1.1.1.1.1.3、4.1.1.3、4.1.1.1.1.3、4.1.1.1.1.1.1.2、4.1、4.1.1.2、4.1.1.2、4.1.1.2、4.1.1.2、4.1.1.2、4.1.1.2、4.1.1.1.1.2、4.rc.0、4.0.0-beta.8、4.0.0-beta.7、4.0.0-beta.6、4.0.0-beta.5、4.0.0-beta.4、4.0.0-beta.3、,
4.0.0-beta.2,4.0.0-beta.1,4.0.0-beta.0,2.4.10,2.4.9,2.4.8,2.4.7,2.4.6,2.4.5,2.4.4,2.4.3,2.4.2,2.4.1,2.4.0,2.3.1,2.3.0,2.3.0-rc.0,2.3.0-beta.1,2。
0.2.0,2.2.0-rc.0,2.2.2.0,2.2.0,2.2.0-rc.0,2.2.0-0,2.2.2.0-beta.1,2.2.2.0-0-1,2.2.2.0-1.0-1,2.2.2.2.2.0-0-1,2.2.2.2.0-0-0-1,2.0-0-1,1,2.0-1,2.0-1,2.0-1.0-1,2.0-1,2.0-1,2.0-1,2.0-1,2.0-1,2.0-1,2.0-1,2.0-0-1,2.0-1,2.0-1,2.0-0-1,2.0-1,2.0-bet测试测试测试测试测试测试测试测试测试-rc.1,2.0.0-rc.0,0.0.0-7,0.0.0-6,0.0.0-5,0.0.0-4,0.0.0-3,0.0.0-2,0.0.0-1,0.0.0-0 npm错误!不要瞄准npm错误!notarget这很可能不是npm本身的问题。npm错误!在大多数情况下都不是目标
您或您的某个依赖项正在请求npm ERR!不瞄准
不存在的包版本。npm错误!不要瞄准npm错误!
notarget它被指定为“gizza”npm ERR的依赖项!无目标

我知道Angular 5仍处于测试阶段,但我想测试它。

编辑:自2017年11月1日起,5.0.0版现已存在

截至目前,angular 5已于2017年11月1日正式发布,
因此,对于那些希望将旧angular应用程序更新为angular 5的用户:

1) Angular团队还提供了一个方便的工具,可以尽可能简单地从任何版本升级到Angular 5

2) 您必须将所有angular软件包升级到5.0版,请运行以下命令:

npm安装@angular/[email protected]^[email protected]/[email protected]^[email protected]/[email protected]^[email protected]/compiler [email protected]^[email protected]@^[email protected]/[email protected]^[email protected]/[email protected]^[email protected]/platform [email protected]^[email protected]/platform browser动态^[email protected]/platform [email protected]^[email protected]/[email protected]@角度/升级@^[email protected]@^5.5.2

3) Angular 5现在还依赖于TypeScript 2.4.2和RxJS 5.5.2,因此您还必须升级这些包

npm安装[email protected]——准确地保存

4) 如果依赖于日期、货币、小数点或百分比管道,则在5中会看到格式的微小更改。对于使用非en us语言环境的应用程序,您需要从@angular/common/i18n\u data/locale\u fr和registerLocaleData(local)导入它和可选的语言环境\u extended\u fr。
有关管道打断更改的详细信息,请执行以下操作:
https://stackoverflow.com/a/47263949/2810015

5) 在任何生命周期事件中使用实现而不是扩展:确保不使用extends OnInit,或在任何生命周期事件中使用扩展。而是使用工具

6) 从HttpModule和Http服务切换到HttpClientModule和HttpClient服务。HttpClient简化了默认的人体工程学(您不再需要映射到json并删除任何不再需要的map(res=>res.json())调用),现在支持类型化返回值和拦截器

7) RxJS 5.5中导入操作符的推荐方法是从RxJS/operators

从“rxjs/operators”导入{map、filter、mergeMap、tap};

我试图在这里解释更多。
https://onlyforcoder.blogspot.in/2017/11/angular-5-upgrade-your-project-To-Angular5.html

发表评论