Angular-cli: Cannot find variable in JS script: Cannot find name 'Hammer'

Created on 24 Mar 2017  路  4Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] WTF?

Versions.


Upgrading everything to RC4 from beta.28 :
@angular/cli: 1.0.0-rc.4
node: 6.10.0
os: darwin x64
@angular/common: 2.4.10
@angular/compiler: 2.4.10
@angular/core: 2.4.10
@angular/forms: 2.4.10
@angular/http: 2.4.10
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 2.4.10
@angular/platform-browser-dynamic: 2.4.10
@angular/router: 3.4.10
@angular/cli: 1.0.0-rc.4
@angular/compiler-cli: 2.4.10

Repro steps.


Reference Hammer: this.whichWayIsUp = Hammer.DIRECTION_VERTICAL

The log given by the failure.

... Cannot find name 'Hammer'

Desired functionality.

NPM installed the hammerjs and pointed it at it in .angular-cli.json scripts tag:

  "scripts": [
    "../node_modules/hammerjs/hammer.min.js",

My assumption (which may be in error) is that we need only include the script and then we can reference the variables in that script (e.g., Hammer). Please advise, thanks!

Mention any other details that might be useful.

Most helpful comment

@chozharajan probably with npm install @types/hammerjs --save-dev

All 4 comments

You'll need to install the types as well: '@types/hammerjs'

@clydin is right. Closing this as answered.

@clydin am new angular can you explain it step by step i can't understand "You'll need to install the types as _well:"_ and @hansl also

@chozharajan probably with npm install @types/hammerjs --save-dev

Was this page helpful?
0 / 5 - 0 ratings

Related issues

naveedahmed1 picture naveedahmed1  路  3Comments

purushottamjha picture purushottamjha  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments

MateenKadwaikar picture MateenKadwaikar  路  3Comments