3

我使用此链接将我的简单 Angular 前端升级到 Angular 7:

更新到 Angular 7

更新时,我收到了几个关于 package.json 和 polyfills.ts 文件的警告:

UPDATE package.json (1313 bytes)
npm WARN @ngtools/webpack@6.1.5 requires a peer of typescript@~2.4.0 || ~2.5.0 || ~2.6.0 || ~2.7.0 || ~2.8.0 || ~2.9.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/compiler@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/core@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/platform-browser-dynamic@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/platform-browser@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/common@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 69 packages, removed 4 packages, updated 16 packages and moved 2 packages in 43.395s
UPDATE package.json (1315 bytes)
UPDATE src/polyfills.ts (3165 bytes)
npm WARN codelyzer@4.2.1 requires a peer of @angular/compiler@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/core@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/platform-browser-dynamic@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/platform-browser@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.2.1 requires a peer of @angular/common@>=2.3.1 <7.0.0 || >6.0.0-beta <7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

我也有来自打字稿(3.0.1)的这个错误:

Error:Initialization error (angular 2 language service). Cannot read property 'CommandTypes' of undefined

任何人都可以提出解决方法来解决这些依赖警告和打字稿错误吗?我需要手动更改依赖项吗?如果是,我需要一个示例如何...

4

2 回答 2

2

问题是您没有这两个软件包的最新版本。

  1. 您需要将您的软件包更新Codelyzer到最新版本。ng update --all应该这样做,否则您也可以package.json手动编辑。

您可以在此处看到该软件包的最新版本(4.5.0)已与 Angular 7 兼容,因此您需要使用它而不是 4.2.1 版本。

  1. 你的也是一样@ngtools/webpack,你需要使用最新版本(见这里,它是 7.0.2)。很可能您的 packages.json 中没有明确包含此文件,因此您可能只需要npm cache clean -f在运行前执行ng update.

如果这仍然不起作用,我建议您删除您的目录,如果您正确更新了您的(手动或通过)node_modules,它将强制从存储库中的最新版本重建所有内容。npm installpackage.jsonng update

于 2018-10-24T08:21:02.970 回答
0

您是否删除了旧node_modules文件夹?如果不是,请删除它,如果它在那里,也删除 package-lock.json。清理 npm 缓存npm cache clean -f并尝试安装所有软件包

于 2018-10-24T08:03:28.937 回答