By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Node.JS Youtube-video-js module blocking


Active Coder
Hi guys I'm stucked in this nodeJS problem, I trying to make an embed youtube server using NodeJS, the base Idea its use and youtube/cdns video with external audio sync, I 've done this in PHP but have some issues for sync.

I used this example https://github.com/markcellus/youtube-video-js/blob/master/examples/youtube-video.html, but is giving this error module from “http://localhost:3000/youtube-video-js/dist/youtube-video.js” was blocked because of a disallowed MIME type.

npm i youtube-video-js

<!-- index.html -->

    const videoElement = document.querySelector('youtube-video');
    // must wait for DOM to be ready and for component to be accessible
    document.addEventListener('DOMContentLoaded', function () {
        // wait for loading
        videoElement.load().then(() => {
            // pause video after two seconds
            const timer = setTimeout(function () {
            }, 2000);

I'm on windows 8, last version of node, i not have bigger experience in NodejS

Interesting issue, which I'd like to understand. When I run your code in Chrome (after adding the missing HTML - please always post COMPLETE code) it gives me this error

Access to script at 'file:///D:/node_modules/youtube-video-js/dist/youtube-video.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.

As I understand it you can't run Node.js code in the browser. I'm not sure what exactly you are doing, why you get a different message and why it refers to http://localhost:3000/youtube-video-js/dist/youtube-video.js. It might help if you provide more details about your setup. Presumable you are using a node.js server ?

I looked up that JS file on Github and pasted the contents into my <script> block, thinking that might work. Unfortunately it reported a syntax error somewhere in the middle of the very long single line 😲

Buy us a coffee!

Top Bottom