[英]Issue upgrade angular 4 to angular 5 from Visual Studio template
I'm trying to update Angular from version 4 to version 5 that is provided by the template in Visual Studio 2017 (File -> New -> Project -> ASP.NET Core Web Application -> Angular). 我正在尝试将Angular从版本4更新到Visual Studio 2017中模板提供的版本5(文件->新建->项目-> ASP.NET Core Web应用程序-> Angular)。
By default, it seems all the angular packages are 4.2.5. 默认情况下,似乎所有的角度包都是4.2.5。 As I'm a novice with Angular, I'd prefer to be on the version for tutorials provided at Angular.IO. 因为我是Angular的新手,所以我希望使用Angular.IO提供的教程版本。 I've tried the following tutorials to get this up to date: 我尝试了以下教程来使它更新:
The tutorials follows the path of: 这些教程遵循以下路径:
packages.json
导航到包含packages.json
的项目文件夹 npm install -g npm-check-updates
运行npm install -g npm-check-updates
ncu -u
运行ncu -u
package-lock.json
, then repeat steps 1-7 如果软件包仍指向Angular 4,请删除package-lock.json
,然后重复步骤1-7 I've tried these steps multiple times in new projects and it never works for me. 我已经在新项目中多次尝试了这些步骤,但对我却永远无效。 I thought maybe it could just be a UI issue and it's not updating it, so I went and put HttpClientModule
with the import of import { HttpClientModule } from '@angular/common/http';
我以为这可能只是一个UI问题,并且没有更新它,所以我去了HttpClientModule
并import { HttpClientModule } from '@angular/common/http';
导入了import { HttpClientModule } from '@angular/common/http';
inside of the app.shared.module.ts
file, but it results with this error: 在app.shared.module.ts
文件中,但导致此错误:
ERROR in C:/Users/kandres/~/@angular/common/esm5/http.js C中的错误:/Users/kandres/~/@angular/common/esm5/http.js
Module not found: Error: Can't resolve '@angular/core' in 'C:\\Users\\\\node_modules\\@angular\\common\\esm5' 找不到模块:错误:无法解析'C:\\ Users \\\\ node_modules \\ @angular \\ common \\ esm5'中的'@ angular / core'
@ C:/Users//~/@angular/common/esm5/http.js 6:0-100 @ C:/用户//~/@angular/common/esm5/http.js 6:0-100
@ ./ClientApp/app/app.shared.module.ts @ ./ClientApp/app/app.shared.module.ts
@ ./ClientApp/app/app.browser.module.ts @ ./ClientApp/app/app.browser.module.ts
@ ./ClientApp/boot.browser.ts @ ./ClientApp/boot.browser.ts
@ multi event-source-polyfill webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true ./ClientApp/boot.browser.ts @ multi event-source-polyfill webpack-hot-middleware / client?path = __ webpack_hmr&dynamicPublicPath = true ./ClientApp/boot.browser.ts
along with 6 other similar errors for rxjs/Observable
, rxjs/observable/of
, rxjs/operator/concatMap
, rxjs/operator/filter
, rxjx/operator/map
, and @angular/core
(again). 以及rxjs/Observable
, rxjs/observable/of
, rxjs/operator/concatMap
, rxjs/operator/filter
, rxjx/operator/map
和@angular/core
其他6个类似错误(再次)。
When I run npm install -g npm-check-updates
I get an error that says: 当我运行npm install -g npm-check-updates
,出现错误npm install -g npm-check-updates
:
npm WARN npm@3.10.10 had bundled packages that do not match the required version(s). npm WARN npm@3.10.10捆绑了与所需版本不匹配的软件包。 They have been replaced with non-bundled versions. 它们已替换为非捆绑版本。
When I run ncu -u
every time it says aspnet-webpack ^2.0.1 -> ^2.0.3
. 当我每次运行ncu -u
时都说aspnet-webpack ^2.0.1 -> ^2.0.3
。 I can rerun that command multiple times and get that same message. 我可以多次重新运行该命令并获得相同的消息。 If I manually change packages.json to make that update, ncu -u
says that all the packages are up to date. 如果我手动更改packages.json进行更新,则ncu -u
表示所有软件包都是最新的。
The result of all of this doesn't make an change though for my project. 尽管对我的项目来说,所有这些结果都没有改变。 All my dependencies for angular 4 still point to version 4.2.5. 我对angular 4的所有依赖关系仍然指向4.2.5版本。 I can't seem to figure out what I'm doing wrong. 我似乎无法弄清楚我在做什么错。
A bit more detailed explanation, hopefully it would be useful. 更加详细的解释,希望它会有所帮助。
Make sure * Microsoft.NET Core SDK 2.1.xxx 确保* Microsoft.NET Core SDK 2.1.xxx - [rc | -[rc | preview | 预览| beta] candidates are uninstalled. Beta]候选人被卸载。 Those come with new templates and will create asp .net core 2.1 - [rc | 这些带有新模板,将创建asp .net core 2.1-[rc | preview | 预览| beta] applications. Beta]应用程序。 Microsoft.NET Core SDK 2.1.xxx * Microsoft.NET Core SDK 2.1.xxx *
Follow the instructions here to install the latest dotnet template separately 请按照此处的说明分别安装最新的dotnet模板
Execute a dotnet new angular Check the generated structure. 执行一个dotnet new angular检查生成的结构。 package.json shall be under ClientApp folder and there would be a lot of references to Angular 5.2.0 package.json应该在ClientApp文件夹下,并且会有很多对Angular 5.2.0的引用
For development purposes, make sure that ASPNETCORE_ENVIRONMENT=Development 出于开发目的,请确保ASPNETCORE_ENVIRONMENT =开发
Everything else is pretty much the same: 其他所有内容几乎相同:
dotnet restore 点网还原
dotnet run 网络运行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.