question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: parse is not a function

See original GitHub issue

Summary

Running honkit in a yarn’d monorepo causes TypeError

  • HonKit version: 4.0.0.

Step to reproduce

  1. git clone https://github.com/island-is/island.is
  2. yarn add --dev honkit
  3. yarn honkit init --log=debug

Any of init, build, serve, etc. will cause the same error.

Expected results

Non-error

Actual results

TypeError: parse is not a function
    at compileUnsafe (/var/home/user/honkit-reproduce/node_modules/cheerio/node_modules/css-select/lib/compile.js:31:14)
    at select (/var/home/user/honkit-reproduce/node_modules/cheerio/node_modules/css-select/index.js:18:49)
    at CSSselect (/var/home/user/honkit-reproduce/node_modules/cheerio/node_modules/css-select/index.js:41:9)
    at exports.find (/var/home/user/honkit-reproduce/node_modules/cheerio/lib/api/traversing.js:34:21)
    at module.exports (/var/home/user/honkit-reproduce/node_modules/cheerio/lib/cheerio.js:81:18)
    at new initialize (/var/home/user/honkit-reproduce/node_modules/cheerio/lib/static.js:26:20)
    at initialize (/var/home/user/honkit-reproduce/node_modules/cheerio/lib/static.js:23:14)
    at Object.parse (/var/home/user/honkit-reproduce/node_modules/@honkit/html/lib/dom.js:17:17)
    at parseSummary (/var/home/user/honkit-reproduce/node_modules/@honkit/html/lib/summary.js:140:19)
    at /var/home/user/honkit-reproduce/node_modules/@honkit/html/lib/index.js:26:19

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
azucommented, Oct 18, 2022

Thanks for report.

I confirmed it. I don’t know why, but it seems that cheerio is broken in your repository. Probably, it is related to yarn 2+ algorithm.

Run following script

const cheerio = require('cheerio');
const $ = cheerio.load('<h2 class="title">Hello world</h2>');

$('h2.title').text('Hello there!');
$('h2').addClass('welcome');

$(".test")
console.log($.html());

and I get same error:

node index.js
/Users/azu/ghq/github.com/island-is/island.is/node_modules/cheerio/node_modules/css-select/lib/compile.js:31
	var token = parse(selector, options);
	            ^

TypeError: parse is not a function
    at compileUnsafe (/Users/azu/ghq/github.com/island-is/island.is/node_modules/cheerio/node_modules/css-select/lib/compile.js:31:14)
    at select (/Users/azu/ghq/github.com/island-is/island.is/node_modules/cheerio/node_modules/css-select/index.js:18:49)
    at CSSselect (/Users/azu/ghq/github.com/island-is/island.is/node_modules/cheerio/node_modules/css-select/index.js:41:9)
    at initialize.exports.find (/Users/azu/ghq/github.com/island-is/island.is/node_modules/cheerio/lib/api/traversing.js:34:21)
    at initialize.module.exports (/Users/azu/ghq/github.com/island-is/island.is/node_modules/cheerio/lib/cheerio.js:81:18)
    at new initialize (/Users/azu/ghq/github.com/island-is/island.is/node_modules/cheerio/lib/static.js:26:20)
    at initialize (/Users/azu/ghq/github.com/island-is/island.is/node_modules/cheerio/lib/static.js:23:14)
    at Object.<anonymous> (/Users/azu/ghq/github.com/island-is/island.is/index.js:4:1)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)

Perhaps updating cheerio might fix it #281

0reactions
azucommented, Oct 18, 2022

I remove https://github.com/island-is/island.is/blob/8476d6741c90742c531e5fe8654718f89d589d61/package.json#L454 and HonKit works. This resolusion affect HonKit’s dependencies.

This issue is resolusion setting issue. https://yarnpkg.com/configuration/manifest/#resolutions

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: parse is not a function on csv-parse - Stack Overflow
Solution was simple. If parse or any other function is not recognized with node require , try getting the function itself as:
Read more >
TypeError: parser is not a function · Issue #518 - GitHub
This error occurs because micromark (https://github.com/micromark/micromark/releases) updated from 2.10.1 to 2.11.0 .
Read more >
How to solve the "is not a function" error in JavaScript
js we use require() to load external modules and files. This can cause, in some cases, an error like this: TypeError: require(...) is...
Read more >
this.liboptions.parse is not a function - You.com - You.com
TypeError : this. libOptions. parse is not a function. Solution: Actually this issue is tracked at WEB-57089, Follow it for updates. It happens...
Read more >
ESLint: TypeError: this.libOptions.parse is not a function | by ...
The error. TypeError: this.libOptions.parse is not a function at ESLint8Plugin.<anonymous> (C:\Program Files\JetBrains\WebStorm ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found