question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not find TypeScript declaration for '../vendor/paho-mqtt'

See original GitHub issue

If you are using TypeScript and you try to install the latest version of aws-amplify you will see the following error:

/Users/username/WebstormProjects/my-project/node_modules/@aws-amplify/pubsub/lib/Providers/MqttOverWSProvider.d.ts
(1,23): Could not find a declaration file for module '../vendor/paho-mqtt'. '/Users/username/WebstormProjects/my-project/node_modules/@aws-amplify/pubsub/lib/vendor/paho-mqtt.js' implicitly has an 'any' type.
  Try `npm install @types/aws-amplify__pubsub` if it exists or add a new declaration (.d.ts) file containing `declare module 'aws-amplify__pubsub';`

Trying to install@types/aws-amplify__pubsub doesnt help as it doesnt exist so the solution is to declare it yourself.

To Reproduce

  1. Error happens when starting up (npm start) a Create React App TypeScript project

Expected behavior No loading errors

Desktop (please complete the following information):

  • OS: OSX
  • Browser: n/a
  • Version: n/a

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
chris-ramoncommented, Sep 24, 2018
  • A temporary fix, working for us:

    npm install @types/paho-mqtt --save-dev
    

    Update your tsconfig.json:

    +  "files": [
    +    "./node_modules/@types/paho-mqtt/index.d.ts"
    +   ]
    
1reaction
orcunorcuncommented, Oct 30, 2019

Same issue with

"amazon-cognito-identity-js": "3.2.0",
"aws-amplify": "1.2.4",
"aws-amplify-react-native": "2.2.3",
"react": "16.8.1",
"react-native": "0.61.3",

error: bundling failed: Error: Unable to resolve module ../vendor/paho-mqtt from node_modules/@aws-amplify/pubsub/lib/Providers/MqttOverWSProvider.js:

None of these files exist:

  • node_modules/@aws-amplify/pubsub/lib/vendor/paho-mqtt(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
  • node_modules/@aws-amplify/pubsub/lib/vendor/paho-mqtt/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not find a declaration file for module 'module-name ...
In Node.js everything works fine, but TypeScript: import {Injector} from '@ts-stack/di' ...
Read more >
How to fix error TS7016: Could not find a declaration file for ...
How to fix error TS7016: Could not find a declaration file for module 'XYZ'. 'file.js' implicitly has an 'any' type · Try `npm...
Read more >
Documentation - Modules .d.ts - TypeScript
If you can't have esModuleInterop: true in your project, such as when you're submitting a PR to Definitely Typed, you'll have to use...
Read more >
Fixing the TS7016 Error | Atomist Blog
4 Terrible Ways (and 4 Better Ways) to fix 'TS7016: Could not find declaration file'. My favorite thing about TypeScript is gradual typing....
Read more >
TypeScript — Type Declaration Files | by Makesh Kumar
Could not find a declaration file for module '<module-name>'. Note: above issue will arise only if we enabled the strict property in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found