honkit / honkit

:book: HonKit is building beautiful books using Markdown - Fork of GitBook

Home Page:https://honkit.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parse config error: "TypeError: Cannot read properties of undefined (reading 'file')"

jos4uke opened this issue · comments

Summary

Running Honkit v4.0.4, along with node v16.19.0 LTS causes TypeError in ParseConfig.js

Step to reproduce

  1. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
  2. nvm install v16.19.0
  3. nvm use v16.19.0
  4. npm install honkit --save-dev
  5. npx honkit init
  6. npx honkit serve

Expected results

Live reload server started on port: 35729
Press CTRL+C to quit ...

Starting server ...
info: 6 plugins are installed 
info: 6 explicitly listed 
info: plugin "livereload" is loaded
info: plugin "highlight" is loaded
info: plugin "search" is loaded
info: plugin "lunr" is loaded
info: plugin "fontsettings" is loaded
info: plugin "theme-default" is loaded
info: found 10 pages 
info: found 34 asset files 
info: >> generation finished with success in 1.3s ! 
Serving book on http://localhost:4000

Actual results

Live reload server started on port: 35729
Press CTRL+C to quit ...

Starting server ...
TypeError: Cannot read properties of undefined (reading 'file')
    at /home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/honkit/lib/parse/parseConfig.js:44:20
    at _fulfilled (/home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/q/q.js:854:54)
    at /home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/q/q.js:816:13)
    at /home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/q/q.js:624:44
    at runSingle (/home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/q/q.js:137:13)
    at flush (/home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/q/q.js:125:13)
    at processTicksAndRejections (node:internal/process/task_queues:78:11)

I tried to comment the offending lines related to TypeError undefined properties in ParseConfig.js:44-46

 40     }).then((result) => {
 41         let values = result ? result.values : {};
 42         values = (0, validateConfig_1.default)(values);
 43         // Set the file
 44 //        if (result.file) {
 45 //            config = config.setFile(result.file);
 46 //        }
 47         // Merge with old values
 48         config = config.mergeValues(values);
 49         return book.setConfig(config);
 50     });

And then run again, and it works:

npx honkit serve

"""output
Live reload server started on port: 35729
Press CTRL+C to quit ...

Starting server ...
info: 6 plugins are installed 
info: 6 explicitly listed 
info: plugin "livereload" is loaded
info: plugin "highlight" is loaded
info: plugin "search" is loaded
info: plugin "lunr" is loaded
info: plugin "fontsettings" is loaded
info: plugin "theme-default" is loaded
info: found 10 pages 
info: found 34 asset files 
info: >> generation finished with success in 1.3s ! 
Serving book on http://localhost:4000
"""
commented

Fmm, I can not reproduce it.

Probably, book.json or book.js is somthing wrong.

Do you have book.json in that directory?

function parseConfig(book) {

Hi @azu

Thanks for your answer.
I do not have any book.json or book.js in my project directory if it is the place I should search for them.
If you refer to another directory, please tell me the right location to search.

Is one of this file mandatory because I don't see any mention to that in the doc?

commented

No, Honkit will work without book.json

https://github.com/azu/honkit-321
This repo is just copied from your reproduce steps.
However, it works.

❯ npx honkit serve --log debug
Live reload server started on port: 35729
Press CTRL+C to quit ...

Starting server ...
debug: readme found at README.md
debug: summary file found at SUMMARY.md
debug: cleanup folder "/Users/azu/ghq/github.com/azu/honkit-321/_book"
info: 6 plugins are installed
info: 6 explicitly listed
info: plugin "livereload" is loaded
info: plugin "highlight" is loaded
info: plugin "search" is loaded
info: plugin "lunr" is loaded
info: plugin "fontsettings" is loaded
info: plugin "theme-default" is loaded
info: found 1 pages
info: found 3 asset files
debug: calling hook "config"
debug: calling hook "init"
debug: copy assets from theme /Users/azu/ghq/github.com/azu/honkit-321/node_modules/@honkit/honkit-plugin-theme-default/_assets/website
debug: copy resources from plugin /Users/azu/ghq/github.com/azu/honkit-321/node_modules/gitbook-plugin-fontsettings/assets
debug: copy resources from plugin /Users/azu/ghq/github.com/azu/honkit-321/node_modules/gitbook-plugin-lunr/assets
debug: copy resources from plugin /Users/azu/ghq/github.com/azu/honkit-321/node_modules/gitbook-plugin-search/assets
debug: copy resources from plugin /Users/azu/ghq/github.com/azu/honkit-321/node_modules/@honkit/honkit-plugin-highlight/css
debug: copy resources from plugin /Users/azu/ghq/github.com/azu/honkit-321/node_modules/gitbook-plugin-livereload/book
debug: copy asset ".gitignore"
debug: copy asset "package-lock.json"
debug: copy asset "package.json"
debug: calling hook "page:before"
debug: calling hook "page"
debug: index page README.md
debug: calling hook "finish:before"
debug: calling hook "finish"
debug: write search index
info: >> generation finished with success in 0.1s !
Serving book on http://localhost:4000

Well using my version of node v16.19.0, whatever honkit version, I ended up with this type error.

Is it the same version you use with your repo?

I cloned your repo and revert my changes in $PROJ/node_modules/honkit/lib/parse/parseConfig.js, and serve it:

nvm use v16.19.0
#Now using node v16.19.0 (npm v8.19.3)

npx honkit serve --log debug
Live reload server started on port: 35729
Press CTRL+C to quit ...

Starting server ...
debug: readme found at README.md 
debug: summary file found at SUMMARY.md 
debug: cleanup folder "/home/jtran1-loc/Documents/EGFV/Projects/Bioinfo/honkit-321/_book" 
info: 6 plugins are installed 
info: 6 explicitly listed 
info: plugin "livereload" is loaded
info: plugin "highlight" is loaded
info: plugin "search" is loaded
info: plugin "lunr" is loaded
info: plugin "fontsettings" is loaded
info: plugin "theme-default" is loaded
info: found 1 pages 
info: found 3 asset files 
debug: calling hook "config" 
debug: calling hook "init" 
debug: copy assets from theme /home/jtran1-loc/.npm/_npx/8ad405cc3f853826/node_modules/@honkit/honkit-plugin-theme-default/_assets/website 
debug: copy resources from plugin /home/jtran1-loc/.npm/_npx/8ad405cc3f853826/node_modules/gitbook-plugin-fontsettings/assets 
debug: copy resources from plugin /home/jtran1-loc/.npm/_npx/8ad405cc3f853826/node_modules/gitbook-plugin-lunr/assets 
debug: copy resources from plugin /home/jtran1-loc/.npm/_npx/8ad405cc3f853826/node_modules/gitbook-plugin-search/assets 
debug: copy resources from plugin /home/jtran1-loc/.npm/_npx/8ad405cc3f853826/node_modules/@honkit/honkit-plugin-highlight/css 
debug: copy resources from plugin /home/jtran1-loc/.npm/_npx/8ad405cc3f853826/node_modules/gitbook-plugin-livereload/book 
debug: copy asset ".gitignore" 
debug: copy asset "package-lock.json" 
debug: copy asset "package.json" 
debug: calling hook "page:before" 
debug: calling hook "page" 
debug: index page README.md 
debug: calling hook "finish:before" 
debug: calling hook "finish" 
debug: write search index 
info: >> generation finished with success in 0.4s ! 
Serving book on http://localhost:4000

And it works as yours
So does it mean something is wrong with my node modules in my project?

For info, I attached an archive with my packages.json and package-lock.
package.tar.gz

I removed all node modules and package files, and restart with a fresh honkit install.
But still the same error occured when serving my project.
Maybe there is something wrong with some markdown files.
Then, when commenting the same lines in $PROJ/node_modules/honkit/lib/parse/parseConfig.js:44-46, and run serve again it works.
Don't know what to think about this.

 rm -r node_modules/ package.json package-lock.json 
 npm install honkit --save-dev

"""output
npm WARN deprecated readdir-scoped-modules@1.1.0: This functionality has been moved to @npmcli/fs
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

added 270 packages, and audited 271 packages in 14s

40 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice 
npm notice New major version of npm available! 8.19.3 -> 9.4.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.4.0
npm notice Run npm install -g npm@9.4.0 to update!
npm notice 
"""

npx honkit serve --log debug

"""output
Live reload server started on port: 35729
Press CTRL+C to quit ...

Starting server ...
TypeError: Cannot read properties of undefined (reading 'file')
    at /home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/honkit/lib/parse/parseConfig.js:44:20
    at _fulfilled (/home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/q/q.js:854:54)
    at /home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/q/q.js:816:13)
    at /home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/q/q.js:624:44
    at runSingle (/home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/q/q.js:137:13)
    at flush (/home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/q/q.js:125:13)
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
npm notice 
npm notice New major version of npm available! 8.19.3 -> 9.4.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.4.0
npm notice Run npm install -g npm@9.4.0 to update!
npm notice 
"""

If $PROJ/node_modules/honkit/lib/parse/parseConfig.js:44-46 lines are commented, and I run honkit serve again, no more error:

npx honkit serve --log debug

"""output
Live reload server started on port: 35729
Press CTRL+C to quit ...

Starting server ...
debug: readme found at README.md 
debug: summary file found at SUMMARY.md 
debug: cleanup folder "/home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/_book" 
info: 6 plugins are installed 
info: 6 explicitly listed 
info: plugin "livereload" is loaded
info: plugin "highlight" is loaded
info: plugin "search" is loaded
info: plugin "lunr" is loaded
info: plugin "fontsettings" is loaded
info: plugin "theme-default" is loaded
info: found 11 pages 
info: found 33 asset files 
debug: calling hook "config" 
debug: calling hook "init" 
debug: copy assets from theme /home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/@honkit/honkit-plugin-theme-default/_assets/website 
debug: copy resources from plugin /home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/gitbook-plugin-fontsettings/assets 
debug: copy resources from plugin /home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/gitbook-plugin-lunr/assets 
debug: copy resources from plugin /home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/gitbook-plugin-search/assets 
debug: copy resources from plugin /home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/@honkit/honkit-plugin-highlight/css 
debug: copy resources from plugin /home/jtran1-loc/Documents/EGFV/Projects/Ext/GenomAsm4pg/node_modules/gitbook-plugin-livereload/book 
debug: copy asset ".config/masterconfig.yaml" 
debug: copy asset ".config/snakemake_profile/slurm/CookieCutter.py" 
debug: copy asset ".config/snakemake_profile/slurm/cluster_config.yml" 
debug: copy asset ".config/snakemake_profile/slurm/config.yaml" 
debug: copy asset ".config/snakemake_profile/slurm/slurm-jobscript.sh" 
debug: copy asset ".config/snakemake_profile/slurm/slurm-status.py" 
debug: copy asset ".config/snakemake_profile/slurm/slurm-submit.py" 
debug: copy asset ".config/snakemake_profile/slurm/slurm_utils.py" 
debug: copy asset ".gitignore" 
debug: copy asset ".gitlab-ci.yml" 
debug: copy asset "job.sh" 
debug: copy asset "prejob.sh" 
debug: copy asset "workflow/Snakefile" 
debug: copy asset "workflow/pre-job_snakefiles/Snakefile1.smk" 
debug: copy asset "workflow/pre-job_snakefiles/Snakefile2.smk" 
debug: copy asset "workflow/pre-job_snakefiles/Snakefile3.smk" 
debug: copy asset "workflow/rules/01_qc.smk" 
debug: copy asset "workflow/rules/02_asm.smk" 
debug: copy asset "workflow/rules/03.5_A_qc_merqury.smk" 
debug: copy asset "workflow/rules/03_asm_qc.smk" 
debug: copy asset "workflow/rules/04_purge_dups.smk" 
debug: copy asset "workflow/rules/05.5_PA_qc_merqury.smk" 
debug: copy asset "workflow/rules/05_purged_asm_qc.smk" 
debug: copy asset "workflow/rules/06_sym_link_hap.smk" 
debug: copy asset "workflow/rules/07_report.smk" 
debug: copy asset "workflow/rules/README.md" 
debug: copy asset "workflow/scripts/FindTelomeres.py" 
debug: copy asset "workflow/scripts/from_config/hifiasm_mode.py" 
debug: copy asset "workflow/scripts/from_config/parameters.py" 
debug: copy asset "workflow/scripts/from_config/target_list.py" 
debug: copy asset "workflow/scripts/hist_plot.py" 
debug: copy asset "workflow/scripts/report.Rmd" 
debug: copy asset "workflow/scripts/report_trio.Rmd" 
debug: calling hook "page:before" 
debug: calling hook "page:before" 
debug: calling hook "page:before" 
debug: calling hook "page:before" 
debug: calling hook "page:before" 
debug: calling hook "page:before" 
debug: calling hook "page:before" 
debug: calling hook "page:before" 
debug: calling hook "page:before" 
debug: calling hook "page:before" 
debug: calling hook "page:before" 
debug: calling hook "page" 
debug: calling hook "page" 
debug: calling hook "page" 
debug: calling hook "page" 
debug: calling hook "page" 
debug: calling hook "page" 
debug: calling hook "page" 
debug: calling hook "page" 
debug: calling hook "page" 
debug: calling hook "page" 
debug: calling hook "page" 
debug: index page README.md 
debug: index page workflow/documentation.md 
debug: index page workflow/doc/Quick-start.md 
debug: index page workflow/doc/Assembly-Mode/Hi-C-tutorial.md 
debug: index page workflow/doc/Assembly-Mode/Trio-tutorial.md 
debug: index page workflow/doc/Outputs.md 
debug: index page workflow/doc/Tar-data-preparation.md 
debug: index page workflow/doc/Going-further.md 
debug: index page workflow/doc/Known-errors.md 
debug: index page workflow/doc/Programs.md 
debug: index page honkit.md 
debug: calling hook "finish:before" 
debug: calling hook "finish" 
debug: write search index 
info: >> generation finished with success in 1.3s ! 
Serving book on http://localhost:4000
"""
commented

Probably, it will be fixed in https://github.com/honkit/honkit/releases/tag/v4.0.8
Please try it.

Thanks for report.