带有角材料声明的角编辑警告

Ard*_*zii 33 angular-material hyperledger-composer angular

在安装Angular Material之后尝试进行编译时,我遇到了一系列警告(无论是直接来自npm还是通过,ng add @angular/material以及是否选择使用动画)。

它可以正常工作而没有任何警告或问题。有人可以帮助我吗?

以下是警告:

git:(master) ? ng serve
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Date: 2019-06-02T16:53:30.127Z
Hash: 790c60ed1be271555fcc
Time: 13875ms
chunk {main} main.js, main.js.map (main) 10.4 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 237 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 181 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 6.73 MB [initial] [rendered]

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2324:55-73
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/bottom-sheet.es5.js 829:56-74
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/datepicker.es5.js 101:59-77
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/icon.es5.js 1027:57-75
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/paginator.es5.js 80:58-76
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/snack-bar.es5.js 1049:53-71
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/sort.es5.js 412:59-77
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/stepper.es5.js 61:56-74
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/bidi.es5.js 91:56-74
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/observers.es5.js 38:65-83
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/observers.es5.js 195:57-75
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 456:55-73
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 1361:62-80
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2038:58-76
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/core.es5.js 1452:59-77
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2956:54-72
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/platform.es5.js 102:50-68
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/layout.es5.js 88:54-72
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/layout.es5.js 314:60-78
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/collections.es5.js 524:67-85
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/scrolling.es5.js 663:58-76
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/scrolling.es5.js 2338:55-73
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 527:63-81
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 824:67-85
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 930:58-76
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 4167:64-82
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 5042:68-86
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/text-field.es5.js 146:57-75
"export '??defineInjectable' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 456:145-153
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/bottom-sheet.es5.js 829:217-225
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 1361:166-174
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/bottom-sheet.es5.js 829:240-248
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2038:154-162
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2038:186-194
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2038:204-212
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/snack-bar.es5.js 1049:139-147
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2324:145-153
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2324:188-196
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/bottom-sheet.es5.js 829:148-156
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2324:226-234
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/snack-bar.es5.js 1049:158-166
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2956:142-150
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2956:160-168
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/snack-bar.es5.js 1049:183-191
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/platform.es5.js 102:130-138
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/snack-bar.es5.js 1049:203-211
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/layout.es5.js 88:142-150
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/snack-bar.es5.js 1049:233-241
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/layout.es5.js 314:160-168
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/layout.es5.js 314:184-192
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/snack-bar.es5.js 1049:260-268
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/text-field.es5.js 146:171-179
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/scrolling.es5.js 663:154-162
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/scrolling.es5.js 663:172-180
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/bottom-sheet.es5.js 829:167-175
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/scrolling.es5.js 2338:145-153
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/scrolling.es5.js 2338:165-173
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/bottom-sheet.es5.js 829:187-195
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 527:169-177
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 527:197-205
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 527:222-230
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 527:240-248
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/bidi.es5.js 91:148-156
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 824:181-189
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/icon.es5.js 1027:151-159
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 930:154-162
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/icon.es5.js 1027:176-184
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 4167:172-180
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 4167:197-205
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 4167:217-225
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 4167:237-245
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/observers.es5.js 195:151-159
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/overlay.es5.js 5042:184-192
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/material/esm5/icon.es5.js 1027:200-208
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/text-field.es5.js 146:151-159
"export '??inject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2324:206-214
"export '??inject' was not found in '@angular/core'
? ?wdm?: Compiled with warnings.
Run Code Online (Sandbox Code Playgroud)

仅当我导入材料模块时才触发:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MatMenuModule } from '@angular/material';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NoopAnimationsModule,
    MatMenuModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)

如果没有导入,编译会顺利进行...这是我的package.json

{
  "name": "central-dev",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~7.1.0",
    "@angular/cdk": "~8.0.0",
    "@angular/common": "~7.1.0",
    "@angular/compiler": "~7.1.0",
    "@angular/core": "~7.1.0",
    "@angular/forms": "~7.1.0",
    "@angular/material": "^8.0.0",
    "@angular/platform-browser": "~7.1.0",
    "@angular/platform-browser-dynamic": "~7.1.0",
    "@angular/router": "~7.1.0",
    "core-js": "^2.5.4",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.11.0",
    "@angular/cli": "~7.1.4",
    "@angular/compiler-cli": "~7.1.0",
    "@angular/language-service": "~7.1.0",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.1.6"
  }
}
Run Code Online (Sandbox Code Playgroud)

这是我跑步时发生的情况npm install

git:(master) npm install 
npm WARN @angular/cdk@8.0.0 requires a peer of @angular/core@^8.0.0 || ^9.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/cdk@8.0.0 requires a peer of @angular/common@^8.0.0 || ^9.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/material@8.0.0 requires a peer of @angular/animations@^8.0.0 || ^9.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/material@8.0.0 requires a peer of @angular/core@^8.0.0 || ^9.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/material@8.0.0 requires a peer of @angular/common@^8.0.0 || ^9.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/material@8.0.0 requires a peer of @angular/forms@^8.0.0 || ^9.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN ajv-keywords@3.4.0 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.

audited 40200 packages in 6.883s
found 3 vulnerabilities (2 low, 1 high)
  run `npm audit fix` to fix them, or `npm audit` for details
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的节点版本:

git:(master) ? node --version
v10.16.0
Run Code Online (Sandbox Code Playgroud)

和我的npm版本:

git:(master) npm --version
6.9.0
Run Code Online (Sandbox Code Playgroud)

最后,当我跑步时会发生什么npm audit fix

无法运行Angular应用程序时出现错误:模式验证失败

它可能没有关系,但是当我尝试参加Hyperledger Composer却不知道发生了什么时,一切都开始了……我看了看网络,但似乎找不到类似的问题……

提前致谢!

****编辑*****试图更新:

git:(master) ng update
^[[C^[[A    We analyzed your package.json, there are some packages to update:

      Name                               Version                  Command to update
     --------------------------------------------------------------------------------
      @angular/cli                       7.1.4 -> 8.0.1           ng update @angular/cli
      @angular/core                      7.1.4 -> 8.0.0           ng update @angular/core
      rxjs                               6.3.3 -> 6.5.2           ng update rxjs


    There might be additional packages that are outdated.
    Run "ng update --all" to try to update all at the same time.
Run Code Online (Sandbox Code Playgroud)

并做了:

centralDev git:(master) ng update --all
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    packageGroup metadata of package @angular/cli is malformed.
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.4 <3.5", would install "3.5.1")
                  Package "@angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=3.1 < 3.5", would install "3.5.1")
                  Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.4 <3.5", would install "3.5.1").
Incompatible peer dependencies found. See above.
Run Code Online (Sandbox Code Playgroud)

最终将其限制为:

git:(master) ng update @angular/cli @angular/core
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    packageGroup metadata of package @angular/cli is malformed.
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    packageGroup metadata of package @angular/cli is malformed.
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    packageGroup metadata of package @angular/cli is malformed. Ignoring.
    Updating package.json with dependency @angular/compiler @ "8.0.0" (was "7.1.4")...
    Updating package.json with dependency @angular/common @ "8.0.0" (was "7.1.4")...
    Updating package.json with dependency @angular/language-service @ "8.0.0" (was "7.1.4")...
    Updating package.json with dependency @angular/animations @ "8.0.0" (was "7.1.4")...
    Updating package.json with dependency @angular/core @ "8.0.0" (was "7.1.4")...
    Updating package.json with dependency @angular/compiler-cli @ "8.0.0" (was "7.1.4")...
    Updating package.json with dependency @angular/forms @ "8.0.0" (was "7.1.4")...
    Updating package.json with dependency zone.js @ "0.9.1" (was "0.8.29")...
    Updating package.json with dependency @angular/platform-browser @ "8.0.0" (was "7.1.4")...
    Updating package.json with dependency @angular/platform-browser-dynamic @ "8.0.0" (was "7.1.4")...
    Updating package.json with dependency rxjs @ "6.5.2" (was "6.3.3")...
    Updating package.json with dependency @angular/router @ "8.0.0" (was "7.1.4")...
    Updating package.json with dependency @angular/cli @ "8.0.1" (was "7.1.4")...
    Updating package.json with dependency typescript @ "3.4.5" (was "3.1.6")...
UPDATE package.json (1373 bytes)

> @angular/cli@8.0.1 postinstall /Users/ardzii/Documents/Angular/centralDev/node_modules/@angular/cli
> node ./bin/postinstall/script.js

npm WARN @ngtools/webpack@7.1.4 requires a peer of @angular/compiler-cli@>=5.0.0 <8.0.0 || ^7.0.0-beta.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngtools/webpack@7.1.4 requires a peer of typescript@>=2.4.0 < 3.2 but none is installed. You must install peer dependencies yourself.
npm WARN ajv-keywords@3.4.0 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.5.0 requires a peer of @angular/compiler@>=2.3.1 <8.0.0 || >7.0.0-beta <8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@4.5.0 requires a peer of @angular/core@>=2.3.1 <8.0.0 || >7.0.0-beta <8.0.0 but none is installed. You must install peer dependencies yourself.

added 51 packages from 22 contributors, removed 44 packages, updated 28 packages, moved 1 package and audited 27777 packages in 142.377s
found 2 vulnerabilities (1 low, 1 high)
  run `npm audit fix` to fix them, or `npm audit` for details
    ** Executing migrations for package '@angular/cli' **
DELETE src/browserslist
CREATE browserslist (388 bytes)
UPDATE tslint.json (2819 bytes)
UPDATE package.json (1375 bytes)
UPDATE src/polyfills.ts (2838 bytes)
UPDATE tsconfig.json (438 bytes)
UPDATE src/tsconfig.app.json (166 bytes)
UPDATE src/tsconfig.spec.json (256 bytes)
added 46 packages from 31 contributors, removed 117 packages, updated 93 packages, moved 13 packages and audited 18839 packages in 55.466s
found 1 low severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details
    ** Executing migrations for package '@angular/core' **
            ------ Static Query Migration ------
            With Angular version 8, developers need to
            explicitly specify the timing of ViewCh

x-m*_*gix 42

您将需要结合Reid和Jens Mander的答案

按以下顺序执行:

npm update @angular/cli @angular/cdk rxjs
npm install -S @angular/material @angular/cdk @angular/animations
npm uninstall @angular/core
npm install -S @angular/core
Run Code Online (Sandbox Code Playgroud)

Angular材料开始为我工作之后

  • 如果在更新过程中,您的角度版本从7切换到8,则还需要运行以下命令:ng update @ angular / cli @ angular / core (2认同)

MAE*_*_DE 9

如果您拥有Angular 7,那么您也应该拥有Angular Material Version 7。所以请安装

npm install @angular/material@7.3.7 
npm install @angular/cdk@7.3.7
Run Code Online (Sandbox Code Playgroud)

如果您有package.json-file删除node_modules文件夹,请在控制台中输入npm install。这应该重新安装所有的node_modules。之后,警告消失了。


小智 8

我也有同样的问题,然后我更改了角形材质的版本。

选项1 :: 您可以使用以下命令来更改角度材质的版本。

npm install --save @angular/material@7.3.7
npm install --save @angular/cdk@7.3.7
Run Code Online (Sandbox Code Playgroud)

您可以在角形材料上查看所有版本列表

选项2: 尝试将角度版本从7更新到8


小智 7

这是一个版本控制问题。如果您打算使用Material 8.0.0,那么您将需要同步版本的补充软件包。请尝试以下方法。

npm update @angular/cli @angular/cdk rxjs
Run Code Online (Sandbox Code Playgroud)

上面的命令完成运行后,从Angular Material文档中运行以下命令

npm install --save @angular/material @angular/cdk @angular/animations
Run Code Online (Sandbox Code Playgroud)

这应该使Angular,Material和RxJS的所有版本保持同步,并准备让您开始在Angular 8项目中使用Angular Material和RxJS。

作为一般的更新检查思路,当您更新Angular或其他任何内容以及相应的软件包时,这些问题一直在弹出。当每个难题都经过测试并且稳定时,像现在一样,尝试在主要版本更新上拉动触发器,这样可以避免卡在依赖地狱中,在该依赖地狱中,应用程序的一部分将不匹配,并使您无法继续建立你想要的。

  • 好的,我不知道自己做了什么,但是以下操作有所帮助:npm卸载@ angular / core,然后npm安装@ angular / core。package.json已修改。 (3认同)

Vis*_*hal 5

只需在package.json中进行一些更改:

@angular/cdk": "^7.0.3"
@angular/material": "^7.0.3"
Run Code Online (Sandbox Code Playgroud)

这些应该与您的角度版本匹配。