-
Notifications
You must be signed in to change notification settings - Fork 903
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
[devOps / Node.js support] requiring ml5 in node.js results in error: ReferenceError: window is not defined #570
Comments
Tenho o mesmo problema. Estou estudando node.js, tensorflow, ml5, etc... pelo que entendi, esse framework ml5 foi criado para rodar diretamente no browser. Tanto é que o objeto BOM window é invocado dentro do ml5.min.js. Se criar um js e rodar a partir de um html vai funcionar. |
@oveddan - Thanks for raising this issue. I've added this to the list of todos for the next coming weeks/months. I'd love for ml5 to be more flexible in this regard. Right now we have issues with supporting ml5 as a npm module and can only really be used via the CDN link. This has to do with calls to the window object that I think might be causing any bundling to break. You've also mentioned how awesome it would be to be able to choose specific ml5 features (e.g. to be able to do If you've got ideas for how we might move this forward, I'm all ears and happy to support. In the meantime, we should def. do our best to make sure ml5 doesn't break in other environments! Thank you! |
@samuelrosacv muito obrigado pra sua messagem. (meu portugeus nao e bom, mas posso falo um poco). Nos esperamos resolver esse "issue" estes proximos semanas. Obrigadao! |
Would love if you could please get it working with Node as well. Thanks! |
Any solution yet? I'm using Nextjs, React and ml5 (v - 0.5) node module and the |
@joeyklee , any solution? |
In Next.js project with |
Hi @Prottoy2938 and @srcnalt - Thanks for your comments here. The changes required here are on our roadmap, but I can't say for sure when this will be resolved. I wish I could give you a better timeline for this, but for the time being there has not been any progress here. The way ml5 is structured at the moment makes calls the |
Thank you for the reply @joeyklee meanwhile I was able to get it working using react hooks, hope it helps others who have the same issue.
|
well its like two years later, guess you never really managed to look into it. |
Any solution for this time? Thank you. |
Would love to see a solution for this. |
@lindapaiste has been working on something check out #1318 |
Still getting the error on v0.10.5 |
Any idea? @joeyklee @lindapaiste |
Still getting the error in version |
I was using ml5 with nextjs and was getting the same error, I resolved this issue by dynamically importing the component which I was rendering in nextJS pages. const MyComponent= dynamic( |
I have a basic program in node.js, where I run:
npm install ml5
This installs ml5 version
0.3.1
When I try to require it in my program with:
I get an error:
(function (exports, require, module, __filename, __dirname) { !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ml5=e():t.ml5=e()}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=698)}([function(t,e,n){"use strict";n.r(e),function(t,r,i,a){n.d(e,"AdadeltaOptimizer",function(){return ml}),n.d(e,"AdagradOptimize
ReferenceError: window is not defined
at Object. (/Users/danoved/Source/in_class_demos/puppeteer_lstm/node_modules/ml5/dist/ml5.min.js:1:250)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/Users/danoved/Source/in_class_demos/puppeteer_lstm/test_chat.js:2:13)
at Module._compile (module.js:652:30)
The text was updated successfully, but these errors were encountered: