-
Notifications
You must be signed in to change notification settings - Fork 29
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
ReferenceError with TextEncoder #143
Comments
Hi , have you managed to solve your issue? I have the same problem, all the function I tried calling came up with ReferenceError: Function is not defined. Function - whichever function I tried calling. Thanks. |
Unfortunately no. I am not very familiar with JS and I only tried this because it seems straightforward. But maybe it is not as easy as it seems to be. |
You are probably trying to use functions which are not part of core JavaScript. See this vignette: https://cran.r-project.org/web/packages/V8/vignettes/npm.html |
Hi,
Thanks for your reply.
I mostly use R but there are some libraries and modules in JS that are needed for my work, hence your V8 appeals a lot as it seems to enable JS to be run from R.
So re: functions - V8 only works for functions that are part of core JavaScript? ‘
The modules/libraries I am trying to load mljs.github.io/spectra-processing/ <http://mljs.github.io/spectra-processing/>.
Since I am not familiar about JavaScript, I am afraid I can’t tell you if their functions are part of core JavaScript or not.
Is it possible to run the call the modules directly from my local drive (I’ve cloned the repo)?
In your Introduction to V8 for R:
ct$source(system.file("js/underscore.js", package="V8”))
Is “js/underscore.js” the source file for package V8? So the package part is to state which module we are calling from the .js file?
Thanks.
… On 28 Nov 2022, at 10:09 pm, Jeroen Ooms ***@***.***> wrote:
You are probably trying to use functions which are not part of core JavaScript. See this vignette: https://cran.r-project.org/web/packages/V8/vignettes/npm.html <https://cran.r-project.org/web/packages/V8/vignettes/npm.html>
—
Reply to this email directly, view it on GitHub <#143 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AJGZ7NKAU7PP2HKG7KOVNCDWKS4H3ANCNFSM5Y66EUDA>.
You are receiving this because you are subscribed to this thread.
|
I used the hints here and saved text-encoding explicitly as another dependency. Doing this will eliminate the error "ReferenceError: TextEncoder is not defined" when sourcing jsdom.js. See my blog post for details: https://nanx.me/blog/post/r-readability-parser/ |
Thanks for the package for bridging JS into R! I was reading JavaScript for R, Chapter 18 and was thinking if I can browserify
jsdom
to be used in R.I have
in.js
:converted by:
and then called in R:
But then I got an error
ReferenceError: TextEncoder is not defined
.My searching on Google told me that it could be Node version problem (using Node 18 first, but noticed V8 engine version 9.6.180.12 and then tried Node 16). But downgrading didn't work. I also tried to hack in
whatwg-url
source code, but then I gotTypeError: util.TextEncoder is not a constructor
error.I am not sure why this is the case (sorry for my not being very proficient in JS), but
jsdom
should work fine withbrowserify
and I think this translation should work out. And potentially I can call jsdom from R via V8.Any help/insight will be appreciated! Thank!
The text was updated successfully, but these errors were encountered: