我在一个有角度的项目中进行测试,并且在这两个测试文件上遇到错误:
这是我按npm test https://pastebin.com/ncTg4WXM
时遇到的错误请给我您的想法
我尝试过:
npm install --save @angular/material
npm install --save @angular/cdk
ng add @angular/material
npm install --save @angular/typings
npm install typings
npm install types
但没有效果
错误消息的摘录:
ERROR in ./src/app/app.component.spec.ts
Module not found: Error: Can't resolve '@angular/material/typings' in '/home/alpha/git/epitome/src/app'
resolve '@angular/material/typings' in '/home/alpha/git/epitome/src/app'
Parsed request is a module
using description file: /home/alpha/git/epitome/package.json (relative path: ./src/app)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
looking for modules in /home/alpha/git/epitome/
using description file: /home/alpha/git/epitome/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
using description file: /home/alpha/git/epitome/package.json (relative path: ./@angular/material/typings)
no extension
Field 'browser' doesn't contain a valid alias configuration
/home/alpha/git/epitome/@angular/material/typings doesn't exist
.ts
答案 0 :(得分:2)
您似乎使用了错误的导入。如果您在official material API中检查了sidenav,则可以看到导入实际上应该是import {MatSidenavModule} from '@angular/material/sidenav';
而不是import {MatSidenavModule} from '@angular/material/typings/sidenav';
。
请注意,首次导入时缺少键入内容。