Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot set property navigator of # which has only a getter #879

Open
giulianopenido opened this issue Aug 14, 2024 · 7 comments

Comments

@giulianopenido
Copy link

I am facing an issue to build an nextjs project using RecordRTC. Just importing the package I receive this error below

TypeError: Cannot set property navigator of # which has only a getter

Looking into the source code, the problem seems to be from this snippet:

// RecordRTC.js at 1586 line
global.navigator = {
  userAgent: browserFakeUserAgent,
  getUserMedia: function() {}
};

@noutijo
Copy link

noutijo commented Aug 21, 2024

I am facing the same issue.

@giulianopenido
Copy link
Author

I found a workaround which is not ideal but will make the build work while the bug is not fixed.

I used a lazy import of the recordrtc module that is only executed right before the place I instantiate the recorder. Make sure this import runs clientside and after hydration.

const RecordRTC = require("recordrtc");

@lagupa
Copy link

lagupa commented Aug 22, 2024

I found a workaround which is not ideal but will make the build work while the bug is not fixed.

I used a lazy import of the recordrtc module that is only executed right before the place I instantiate the recorder. Make sure this import runs clientside and after hydration.

const RecordRTC = require("recordrtc");

How do you support typescript then if you import it this way?

@fbn776
Copy link

fbn776 commented Oct 2, 2024

Hello.. I'm using this lib with nextjs 14 and facing the same issue. I tried the workaround and still facing the same issue. Any fixes?

@NikhilDangiAcademy
Copy link

Facing issue
const recorder = new RecordRTC.RecordRTCPromisesHandler(
stream, { type: "video" }
);
TypeError: Cannot set property navigator of # which has only a getter

Technology : Next.js with Typescript

@RaiaN
Copy link

RaiaN commented Dec 7, 2024

The same issue

@NikhilDangiAcademy
Copy link

The same issue

use const stream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: { width: 430, height: 430, facingMode: "user" },
});
streamRef.current = stream;

  if (videoRef.current) {
    videoRef.current.srcObject = stream;
    videoRef.current.play();
  }

  const mimeType = "video/webm;codecs=vp8";
  if (!MediaRecorder.isTypeSupported(mimeType)) {
    console.warn(`${mimeType} is not supported. Using default MIME type.`);
  }

  const mediaRecorder = new MediaRecorder(stream, {
    mimeType: MediaRecorder.isTypeSupported(mimeType)
      ? mimeType
      : undefined,
  });

  mediaRecorderRef.current = mediaRecorder;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants