-
Notifications
You must be signed in to change notification settings - Fork 549
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
"Error: Cannot find module 'videojs'" when bundling using ES6/Babel and VideoJS 5 #343
Comments
Update to 2.0.6 and it should work fine. The require was on videojs instead of video.js. My bad. Let me know if it works for you! |
Fantastic, 2.0.6 resolves this issue for me! Thanks for the hard work on this project and for responding so quickly to my issue report 😄 |
@eXon Possibly related, but I can't get it to build either using this same import structure:
Building with webpack, on 2.0.7 |
@Fireworks Are you using RequireJS or CommonJS? I think I forgot to fix it for RequireJS |
@eXon Webpack, which can handle CommonJS fine, so not sure where it's getting caught up. |
I've since moved to webpack and have the same issue now. The reason being it seems that webpack can't find a module named @Fireworks Did you ever figure out what was going on here? Is it an issue with videojs-youtube or a webpack configuration issue? |
@gpmcadam No, I poked around for a bit, but ultimately didn't have time to investigate so I am just using YouTube embedding instead at the moment. |
@gpmcadam Try to upgrade to the last version (remove the node_modules/vjs-youtube folder). It has been fixed in a previous version. Let me know if it works |
I'm using Webpack too and can confirm that it doesn't work with My imports: import videojs from 'video.js';
import 'videojs-youtube'; Error message:
|
So apparently after webpack does its dependency wiring magic, /*global define, YT*/
(function (root, factory) {
if(typeof define === 'function' && define.amd) {
define(['videojs'], function(videojs){
return (root.Youtube = factory(videojs));
});
} else if(typeof module === 'object' && module.exports) {
module.exports = (root.Youtube = factory(require('video.js')));
} else {
root.Youtube = factory(root.videojs);
}
}(this, function(videojs) { [...] } So I thought Webpack might be importing videojs-youtube as an AMD module, not a CommonJS one, which explains why it worked in Browserify but not Webpack. So I tried explicitly disabling AMD, and it did import without error: require('imports?define=>false!videojs-youtube'); UPDATE: Before someone tries using VideoJS with React (like me), note that it's far from trivial and you might want to look elsewhere: videojs/video.js#2006 . I think I'll give up VJS for now. |
This has been fixed in the last revision |
@eXon Hi dude, The latest version 2.4.0 uses the define(['videojs'], function(){}) I think it should be video.js? I meet this error again, and update it to video.js manually works for me. I use 2.0.8 now. So 2.0.8 is the latest release version? |
I am still getting this error in 2018. If you end up here like me from your google search, I was able to solve it by adding: new webpack.ProvidePlugin({
videojs: 'video.js/dist/video.cjs.js'
}), and into
which made my build pass. |
Getting this error on Windows. Unix systems seem to work fine. Updating the |
Additional fix for videojs#343. Youtube.js defines a module with a dependency on `videojs` when it should be `video.js`.
I'm hoping PR #565 addresses the issue workarounds, like aliasing, aren't necessary. |
I'm currently trying to compile ES6 using Babel and Browserify. The VideoJS blog post suggests something like this should work:
However I'm getting the following error during bundling:
Is the VideoJS YouTube plugin compatible with ES6/Babel in the way suggested by the VideoJS blog post?
The text was updated successfully, but these errors were encountered: