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
TypeError: cheerio.fromURL is not a function #3391
Comments
I am experiencing this issue as well, except it occurs when I call |
Please disregard. The solution to this was. const cheerio = require("cheerio");
// ...
const cheerio_file_dom = cheerio.load(current_file_contents);
// ...
const script_elements = cheerio_file_dom("script[src$=.js]");
script_elements.each((index, current_script_elements) => {
const original_src_value = current_script_elements.attribs["src"];
const new_value = `{{ require_js(get_asset_url(".${original_src_value}")) }}`;
cheerio_file_dom(current_script_elements).replaceWith(new_value);
}); I think @user4302 may be incorrectly referencing the wrong object for the |
i was following this guide in the docs |
@user4302 I encountered this same issue with .fromURL. I think it is because this function is not yet available in the published npm package for Cheerio. The top of the website mentions "Cheerio's website is still a work-in-progress, and covers Cheerio's next release that isn't available yet." If you look in the Github Cheerio repository, you can find the function .from URL in cheerio/src/batteries. However, in the npm package, this path does not exist. Using this code achieved the same goal as using fromURL for me:
|
Hmm I got into this trap as well hehe. The .fromURL() it's not there anymore :) |
I agree with @allison-truhlar, performing the get request yourself using something like Axios seems to be the way to go. |
i use the following code
and i get the following error
TypeError: cheerio.fromURL is not a function
The text was updated successfully, but these errors were encountered: