简体   繁体   English

从Visual Studio模板发布将Angle 4升级到angular 5

[英]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: 这些教程遵循以下路径:

  1. Create new ASP.NET Core 2 Web Application with Angular chosen as the template 以Angular为模板创建新的ASP.NET Core 2 Web应用程序
  2. Close Visual Studio 关闭Visual Studio
  3. Open node.js command prompt or powershell as administrator 以管理员身份打开node.js命令提示符或Powershell
  4. Navigate to the project folder containing packages.json 导航到包含packages.json的项目文件夹
  5. Run npm install -g npm-check-updates 运行npm install -g npm-check-updates
  6. Run ncu -u 运行ncu -u
  7. Reopen Visual Studio 重新打开Visual Studio
  8. If packages are still pointing to Angular 4, delete package-lock.json , then repeat steps 1-7 如果软件包仍指向Angular 4,请删除package-lock.json ,然后重复步骤1-7
  9. Fix some code issues at outlined in the article 解决本文概述的一些代码问题

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问题,并且没有更新它,所以我去了HttpClientModuleimport { 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/Observablerxjs/observable/ofrxjs/operator/concatMaprxjs/operator/filterrxjx/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. 更加详细的解释,希望它会有所帮助。

  1. 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 *

  2. Follow the instructions here to install the latest dotnet template separately 请按照此处的说明分别安装最新的dotnet模板

  3. 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的引用

  4. For development purposes, make sure that ASPNETCORE_ENVIRONMENT=Development 出于开发目的,请确保ASPNETCORE_ENVIRONMENT =开发

  5. Everything else is pretty much the same: 其他所有内容几乎相同:

    dotnet restore 点网还原

    dotnet run 网络运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM