【问题标题】:How to update Angular to specific version (required by Google Maps)?如何将 Angular 更新到特定版本(谷歌地图要求)?
【发布时间】:2017-10-02 16:44:44
【问题描述】:

我们如何将 angular 更新到其最新版本以及相应地更新 package.json 的最佳实践是什么,我需要将 @angular 2.2.0 更新到 @angular 2.2.3,请有人可以在这里写 npm 命令吗?我需要更新,因为 Angular 谷歌地图不适用于以前的版本,应用程序抛出异常知道为什么吗?非常感谢您的回答:)

app/listings/residentialListing/shared/resListing.service.ts(22,27):
error TS2339: Property 'find' does not exist on type 'Res
identialListingModel[]'.
app/listings/residentialListing/shared/resListing.service.ts(22,32):
error TS7006: Parameter 'listing' implicitly has an 'any'  type.
node_modules/@agm/core/services/managers/marker-manager.d.ts(9,25):
error TS2304: Cannot find name 'Map'.
node_modules/@angular/common/src/directives/ng_class.d.ts(48,34):
error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/aot/compiler.d.ts(56,32): error
TS2304: Cannot find name 'Map'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(371,20):
error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(373,28):
error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(375,15):
error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(377,23):
error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(379,17):
error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(381,25):
error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/output/output_ast.d.ts(458,63):
error TS2304: Cannot find name 'Set'.
node_modules/@angular/core/src/change_detection/differs/default_iterable_differ.d.ts(28,32):
error TS2304: Cannot find name 'I terable'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,16):
error TS2304: Cannot find name 'M ap'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(32,16):
error TS2304: Cannot find name 'M ap'.
node_modules/@angular/core/src/change_detection/differs/iterable_differs.d.ts(15,48):
error TS2304: Cannot find name 'Iterable '.
node_modules/@angular/core/src/change_detection/differs/keyvalue_differs.d.ts(23,18):
error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(87,123):
error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(87,165):
error TS2304: Cannot find name 'Map'.
node_modules/@angular/http/src/headers.d.ts(52,71): error TS2304:
  Cannot find name 'Map'.
node_modules/@angular/http/src/url_search_params.d.ts(46,16): error
TS2304: Cannot find name 'Map'.
node_modules/@angular/platform-browser/src/browser/browser_adapter.d.ts(79,33):
error TS2304: Cannot find name 'Map'.
node_modules/@angular/platform-browser/src/dom/dom_adapter.d.ts(97,42):
error TS2304: Cannot find name 'Map'.
node_modules/@angular/platform-browser/src/dom/shared_styles_host.d.ts(11,30):
error TS2304: Cannot find name 'Set'.
node_modules/@angular/platform-browser/src/dom/shared_styles_host.d.ts(22,30):
error TS2304: Cannot find name 'Set'.
node_modules/@angular/router/src/router_outlet_context.d.ts(42,28):
error TS2304: Cannot find name 'Map'.
node_modules/@angular/router/src/router_outlet_context.d.ts(43,34):
error TS2304: Cannot find name 'Map'.
node_modules/rxjs/Observable.d.ts(58,60): error TS2693: 'Promise' only
refers to a type, but is being used as a value here.
node_modules/rxjs/operator/toPromise.d.ts(3,79): error TS2693:
  'Promise' only refers to a type, but is being used as a value h ere.
npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR!
product-management@1.0.0 start: `tsc && concurrently "tsc -w"
"lite-server" ` npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the
product-management@1.0.0 start script. npm ERR! This is probably not a
problem with npm. There is likely additional logging output above.
>
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\Amina\AppData\Roaming\npm-cache\_logs\2017-10-02T17_11_05_451Z-debug.log

【问题讨论】:

  • 我需要更新,因为 Angular 谷歌地图不适用于以前的版本,应用程序抛出异常知道为什么吗?
  • 在确切的异常中发布您的代码
  • 刚刚更新了我的问题,请查看。
  • 将所有2.1.2 更改为例如4.3.6。删除 node_modules 并运行 npm i

标签: angular google-maps typescript


【解决方案1】:

要将 Angular 更新到最新版本,只需从 npm 控制台运行以下命令:

Windows

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

Linux

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

记得从安装了 Angular 的文件夹中运行它。为此:

-- 打开 npm 控制台(当你想编译任何 Angular 项目时运行的应用程序。它看起来像 CMD windows 控制台)。

-- 导航到安装了 Angular 的文件夹 (NodeJS)(通常在 ProgramFiles 中)。

-- 粘贴此命令并运行它。

我测试了 windows 版本,它适用于我...

希望对您有所帮助,如有任何疑问,请告诉我。

【讨论】:

  • Elias,我已经完成了,没有运气仍然应用程序抛出不同的异常,似乎@agm 导致了一个实际问题。请检查我更新的问题。
  • 嗨@Amina。你是从 Angular 文件夹做的吗?
  • 我的意思是你必须从 angular 文件夹运行这个命令来检查所有组件及其链接。具体来说,我没有检查 agm,但首先我从 angular 文件夹中运行此命令,但在查找不同组件时遇到了一些错误...
  • 不,我只是从终端中打开的索引文件中提取它然后执行,我需要再次运行它吗?
  • 刚刚从 angular 文件夹更新版本,应用程序抛出相同的异常列表,在问题中提及。
猜你喜欢
  • 1970-01-01
  • 2022-09-25
  • 1970-01-01
  • 2018-01-11
  • 1970-01-01
  • 1970-01-01
  • 2018-05-13
  • 2016-12-02
  • 1970-01-01
相关资源
最近更新 更多