我通过1.0.0-beta.11-webpack.2
将我的Angular 2 CLI项目从1.0.0-beta.11-webpack.8
更新为ng init
。我的项目使用Angular 2.0.0-rc.5
和Angular Material 2.0.0-alpha.7-4
但是当使用ng serve
运行时,我收到以下错误:
ERROR in ./src/app/app.module.ts
Module not found: Error: Can't resolve 'hammerjs' in '/home/jan/src/fm-repos/fm-ui/src/app'
@ ./src/app/app.module.ts 38:0-18
@ ./src/app/index.ts
@ ./src/main.ts
@ multi main
ERROR in [default] /home/jan/src/fm-repos/fm-ui/node_modules/@angular2-material/core/gestures/MdGestureConfig.d.ts:4:39
Cannot find name 'HammerManager'.
ERROR in [default] /home/jan/src/fm-repos/fm-ui/node_modules/@angular2-material/slide-toggle/slide-toggle.d.ts:67:19
Cannot find name 'HammerInput'.
ERROR in [default] /home/jan/src/fm-repos/fm-ui/node_modules/@angular2-material/slider/slider.d.ts:50:19
Cannot find name 'HammerInput'.
ERROR in [default] /home/jan/src/fm-repos/fm-ui/node_modules/@angular2-material/slider/slider.d.ts:52:24
Cannot find name 'HammerInput'.
答案 0 :(得分:21)
要解决此错误,请暂时将hammerjs
添加到项目中:
npm install hammerjs --save
npm install @types/hammerjs --save-dev
并导入模块定义:
/** TODO: remove when work-around is not needed*/
import 'hammerjs';
@NgModule({
declarations: [
AppComponent,
HeaderComponent,
// ...
答案 1 :(得分:2)
我遇到了问题
npm uninstall hammerjs --save
然后npm install hammerjs@latest
解决了我的问题
hammerjs最新安装的版本是2.0.8 角度为5.2.11