MQTT.js icon indicating copy to clipboard operation
MQTT.js copied to clipboard

Vite^2.6.4 + Vue^3.2.16 + TypeScript^4.4.3 Use error reporting

Open sunjunjie1314520 opened this issue 2 years ago • 6 comments

  1. step image
  2. step image 3.step image The console reported an error What do I need to do

sunjunjie1314520 avatar Mar 14 '22 09:03 sunjunjie1314520

same as you,and I use the "vite": "^2.8.0" "vue": "^3.2.25", without Typescript

nanxfu avatar Mar 19 '22 14:03 nanxfu

文件已收到!谢谢!

sunjunjie1314520 avatar Mar 19 '22 14:03 sunjunjie1314520

I solved this proble with #1269

  • Use import * as mqtt from 'mqtt/dist/mqtt.min';

  • Add "skipLibCheck": true to your tsconfig.json

  • Create a shims-mqtt.d.ts with

declare module 'mqtt/dist/mqtt.min' {
  import MQTT from 'mqtt'
  export = MQTT
}

nanxfu avatar Mar 19 '22 14:03 nanxfu

Not work use " "vite": "^2.9.5", "typescript": "^4.6.3", "vue": "^3.2.33"" . Any better idea?

kkstun avatar Apr 25 '22 08:04 kkstun

我用#1269解决了这个问题

  • 利用 import * as mqtt from 'mqtt/dist/mqtt.min';
  • 添加"skipLibCheck": true 到您的 tsconfig.json
  • 创建一个 shims-mqtt.d.ts
declare module 'mqtt/dist/mqtt.min' {
  import MQTT from 'mqtt'
  export = MQTT
}

谢谢,我也遇到了同样的问题

BoBoDinachen avatar Aug 12 '22 04:08 BoBoDinachen

文件已收到!谢谢!

sunjunjie1314520 avatar Aug 12 '22 04:08 sunjunjie1314520

I solved this proble with #1269

  • Use import * as mqtt from 'mqtt/dist/mqtt.min';
  • Add "skipLibCheck": true to your tsconfig.json
  • Create a shims-mqtt.d.ts with
declare module 'mqtt/dist/mqtt.min' {
  import MQTT from 'mqtt'
  export = MQTT
}

我用上边的代码解决后,又出现了新问题:

image

Calerme avatar Sep 24 '22 01:09 Calerme

文件已收到!谢谢!

sunjunjie1314520 avatar Sep 24 '22 01:09 sunjunjie1314520

I solved this proble with #1269

  • Use import * as mqtt from 'mqtt/dist/mqtt.min';
  • Add "skipLibCheck": true to your tsconfig.json
  • Create a shims-mqtt.d.ts with
declare module 'mqtt/dist/mqtt.min' {
  import MQTT from 'mqtt'
  export = MQTT
}

我用上边的代码解决后,又出现了新问题:

image

我又尝试了如下办法解决了这个问题:

  1. mqtt 版本降低为 4.0.1
  2. 引用改为 import mqtt from "mqtt/dist/mqtt.min";

Calerme avatar Sep 24 '22 02:09 Calerme

文件已收到!谢谢!

sunjunjie1314520 avatar Oct 11 '22 07:10 sunjunjie1314520

MQTT 5.0.0 BETA is now available! Try it out and give us feedback: npm i mqtt@beta. It may fix your issues

robertsLando avatar Jul 21 '23 14:07 robertsLando

文件已收到!谢谢!

sunjunjie1314520 avatar Jul 21 '23 14:07 sunjunjie1314520