Typescript and JQuery compile error: Cannot find name '$'

前端 未结 5 2100
醉梦人生
醉梦人生 2021-02-05 03:13

I\'m testing typescript with jquery, but when I compile the test.ts file, it always gives me an error indicating: Cannot find name \'$\'.

I\'ve already imported jquery &

5条回答
  •  醉话见心
    2021-02-05 03:58

    If you find these errors 90% of the time its because of versioning Problem of @types/jquery

    Try running:

     npm install jquery --save
    

    Then in app.module.ts:

    import * as $ from 'jquery';
    

    Then run:

      npm install @types/jquery@2.0.47
    

    And you should be ready to go.

提交回复
热议问题