react-speech-recognition icon indicating copy to clipboard operation
react-speech-recognition copied to clipboard

Failed to resolve import "web-worker:./worker" from "node_modules\@speechly\browser-client\src\websocket\webWorkerController.ts". Does the file exist?

Open YoussefZidan opened this issue 2 years ago • 3 comments

I completed the polyfill as instructed in the documentation in an attempt to use the app across browsers, but I still receive the following issue from node modules.

this happens with version 1.2.0

node_modules/@speechly/browser-client/src/websocket/webWorkerController.ts:2:0

1  |  import { WebsocketResponseType, WorkerSignal, ControllerSignal } from "./types";
2  |  import WebsocketClient from "web-worker:./worker";
   |                               ^
3  |  export class WebWorkerController {
4  |    constructor() {

YoussefZidan avatar Aug 14 '22 13:08 YoussefZidan

I downgraded the version from 1.2.0 to 1.1.0 and the problem was solved!

YoussefZidan avatar Aug 14 '22 13:08 YoussefZidan

Hi @YoussefZidan Version 1.2.0 upgraded the Speechly Browser Client to a new major version, one that seems to introduce this TypeScript-based module import (the module is declared in a TypeScript declaration file here). Without the TypeScript compiler, this import wouldn't work. Your IDE might complain about it if TypeScript is not installed.

However, that library compiles its code to JavaScript and resolves the modules for you. So it shouldn't affect the development or compilation of your web app. To help me understand if this is a problem affecting other developers, can you confirm the following:

  • When exactly do you see this error? When viewing the file in your IDE or when compiling your web app?
  • Which React framework do you use? i.e. Next.js vs Create React App, etc
  • Inside your node_modules, do you have the following file? node_modules/@speechly/browser-client/core/speechly.es.js This is the JavaScript file I would expect to be used when compiling your web app

JamesBrill avatar Oct 08 '22 10:10 JamesBrill

Hi @JamesBrill

  • It happens when serving the app.
  • I'm using React with Vite, following this guide: https://vitejs.dev/guide
  • Yes, I have the file.

YoussefZidan avatar Oct 11 '22 10:10 YoussefZidan