gpt4 book ai didi

angular - 找不到模块 : Error: Can't resolve 'hammerjs'

转载 作者:太空狗 更新时间:2023-10-29 17:02:15 26 4
gpt4 key购买 nike

我将我的 Angular 2 CLI 项目从 1.0.0-beta.11-webpack.2 更新为 1.0.0-beta.11-webpack.8 通过 ng 初始化。我的项目使用 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'.

最佳答案

要解决此错误,请暂时将 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,
// ...

关于angular - 找不到模块 : Error: Can't resolve 'hammerjs' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39496267/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com