Skip to content
the poor coder

VIDEOJS: TypeError: Class constructor Component$1 cannot be invoked without 'new'

Poor Man
Published
Reading time
2 min read
On this page

VIDEOJS: TypeError: Class constructor Component$1 cannot be invoked without 'new'#

If you are a developer and working with VideoJS, you might have come across this error message: TypeError: Class constructor Component$1 cannot be invoked without 'new'. This error message is thrown when the code is trying to instantiate a new instance of the VideoJS component, but it is not being done correctly.

Reasons for the error#

  • One of the most common reasons for this error is that the component is not being imported correctly or is being imported in the incorrect way.
  • Another reason could be that there is a version conflict between the VideoJS library and another library.
  • It could also be caused by a typo or syntax error in the code.

How to fix the error#

The fix for this error depends on the cause of the error. Here are some solutions that might help:

1. Check your imports

The first step is to check your imports. Make sure that you are importing the VideoJS component correctly and in the right way.

Text

// Correct way to import VideoJS component
import videojs from 'video.js';

// Incorrect way to import VideoJS component
import { videojs } from 'video.js';

2. Check for version conflicts

You should also check for version conflicts between the VideoJS library and other libraries that you are using. You can try downgrading or upgrading the conflicting libraries to resolve this issue.

3. Check your code for typos or syntax errors

Double-check your code for any typos or syntax errors. These are common causes of this error message.

4. Use the 'new' keyword to create a new instance

If you are not already using the 'new' keyword to create a new instance of the VideoJS component, you should do so. This will resolve the error message.

Text

// Incorrect way to create a new instance of the VideoJS component
var player = videojs('my-player');

// Correct way to create a new instance of the VideoJS component
var player = new videojs('my-player');

Conclusion#

If you encounter the error message "VIDEOJS: TypeError: Class constructor Component$1 cannot be invoked without 'new'", don't panic. Check your imports, look for version conflicts, double-check your code for typos or syntax errors, and make sure you are using the 'new' keyword to create a new instance of the VideoJS component.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC