Unable to find typings.d.ts and declare modules in angular 2 typescript app

前端 未结 3 1111
死守一世寂寞
死守一世寂寞 2021-01-05 02:55

I am new to Typescript and Angular 2. I need to install an npm dependency and use it in my angular 2 app.

The dependency is https://www.npmjs.com/package/ng2-stomp-s

相关标签:
3条回答
  • 2021-01-05 03:39

    If you are not using new version of angular you can't find typings.d.ts file in your project. My suggestion is to update your project using angular CLI https://cli.angular.io/

    0 讨论(0)
  • 2021-01-05 03:45

    My two cents to this conversation:

    In your tsconfig.json file make sure that you have the right path for your typings.d.ts file

    "typeRoots": [ "node_modules/@types", "../src/typings.d.ts" ],

    0 讨论(0)
  • 2021-01-05 03:54

    It seems like your Typescript compiler tries to compile files from node_modules directory.

    Please make sure you have this excluding rule in your tsconfig.json file:

    { 
      "compilerOptions": {},
      "exclude": [
        "node_modules"
      ]
    }
    

    Btw. you need just one of @types and typings. The second one is deprecated, all you need is proper @types packages included in your dev dependencies. Hope it helps!

    EDIT: I think there shouldn't be any Typescript files in npm package, so I've created a topic with fix on this repository's github: https://github.com/devsullo/ng2-STOMP-Over-WebSocket/issues/5

    0 讨论(0)
提交回复
热议问题