LuxDL / DocumenterVitepress.jl

Documentation with Documenter.jl and VitePress
https://luxdl.github.io/DocumenterVitepress.jl/
MIT License
62 stars 9 forks source link

Mismatch between npm and node #122

Closed korsbo closed 1 month ago

korsbo commented 2 months ago

Hi, I'm afraid that I don't have a simple reproducer, but I occasionally seem to get some error that seems to arise from a version mismatch between npm and node:

[ Info: DocumenterVitepress: building Vitepress site.
ERROR: npm v10.2.4 is known not to run on Node.js v10.19.0.  This version of npm supports the following node versions: `^18.17.0 || >=20.5.0`. You can find the latest version at [https://nodejs.org/.](https://nodejs.org/)

ERROR:
/build/.julia/artifacts/f66014744496ef887b3e70e4fa3ff1fd116ce629/lib/node_modules/npm/lib/utils/exit-handler.js:19
  const hasLoadedNpm = npm?.config.loaded
                           ^

SyntaxError: Unexpected token .
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at module.exports (/build/.julia/artifacts/f66014744496ef887b3e70e4fa3ff1fd116ce629/lib/node_modules/npm/lib/cli-entry.js:15:23)
    at module.exports (/build/.julia/artifacts/f66014744496ef887b3e70e4fa3ff1fd116ce629/lib/node_modules/npm/lib/es6/validate-engines.js:39:10)
    at module.exports (/build/.julia/artifacts/f66014744496ef887b3e70e4fa3ff1fd116ce629/lib/node_modules/npm/lib/cli.js:4:31)
ERROR: LoadError: failed process: Process(`/build/.julia/artifacts/f66014744496ef887b3e70e4fa3ff1fd116ce629/bin/npm install`, ProcessExited(1)) [1]

Stacktrace:
  [1] pipeline_error
    @ ./process.jl:565 [inlined]
  [2] run(::Cmd; wait::Bool)
    @ Base ./process.jl:480
  [3] run
    @ ./process.jl:477 [inlined]
  [4] (::DocumenterVitepress.var"#7#9"{MarkdownVitepress, String})()
    @ DocumenterVitepress ~/.julia/packages/DocumenterVitepress/AH5XK/src/writer.jl:[186](https://github.com/PumasAI/DeepPumas.jl/actions/runs/8939019518/job/24554755713#step:9:187)
  [5] cd(f::DocumenterVitepress.var"#7#9"{MarkdownVitepress, String}, dir::String)
    @ Base.Filesystem ./file.jl:112
  [6] render(doc::Documenter.Document, settings::MarkdownVitepress)
    @ DocumenterVitepress ~/.julia/packages/DocumenterVitepress/AH5XK/src/writer.jl:180
  [7] runner(::Type{DocumenterVitepress.MarkdownFormat}, fmt::MarkdownVitepress, doc::Documenter.Document)
    @ DocumenterVitepress ~/.julia/packages/DocumenterVitepress/AH5XK/src/DocumenterVitepress.jl:27
  [8] dispatch(::Type{Documenter.FormatSelector}, ::MarkdownVitepress, ::Vararg{Any})
    @ Documenter.Selectors ~/.julia/packages/Documenter/CJeWX/src/utilities/Selectors.jl:170
  [9] render(doc::Documenter.Document)
    @ Documenter ~/.julia/packages/Documenter/CJeWX/src/writers.jl:45
 [10] runner(::Type{Documenter.Builder.RenderDocument}, doc::Documenter.Document)
    @ Documenter ~/.julia/packages/Documenter/CJeWX/src/builder_pipeline.jl:258
 [11] dispatch(::Type{Documenter.Builder.DocumentPipeline}, x::Documenter.Document)
    @ Documenter.Selectors ~/.julia/packages/Documenter/CJeWX/src/utilities/Selectors.jl:170
 [12] #86
    @ ~/.julia/packages/Documenter/CJeWX/src/makedocs.jl:248 [inlined]
 [13] withenv(::Documenter.var"#86#88"{Documenter.Document}, ::Pair{String, Nothing}, ::Vararg{Pair{String, Nothing}})
    @ Base ./env.jl:257
 [14] #85
    @ ~/.julia/packages/Documenter/CJeWX/src/makedocs.jl:247 [inlined]
 [15] cd(f::Documenter.var"#85#87"{Documenter.Document}, dir::String)
    @ Base.Filesystem ./file.jl:112
 [16] #makedocs#84
    @ ~/.julia/packages/Documenter/CJeWX/src/makedocs.jl:247 [inlined]

I get that pretty randomly in CI and I have a colleague who had another issue that indicated that 'npm istall' in https://github.com/LuxDL/DocumenterVitepress.jl/blob/79acc709aaa9322d2d02d25442ac2c96ed8a73dc/src/writer.jl#L186 was trying to use a nonexistent global node in /usr/.... rather than the asset in ~/.julia/artifacts/.../bin/node that we should get from NodeJS_20_jll. I figure that this might explain how one can get a node / npm version mismatch like the error msg indicates.

My colleagues stacktrace:

\[ Info: DocumenterVitepress: building Vitepress site.
/usr/bin/env: 'node': No such file or directory
ERROR: LoadError: failed process: Process(`/home/jrun/data/.julia/artifacts/f66014744496ef887b3e70e4fa3ff1fd116ce629/bin/npm install`, ProcessExited(127)) [127]

Stacktrace:
  [1] pipeline_error
    @ ./process.jl:565 [inlined]
  [2] run(::Cmd; wait::Bool)
    @ Base ./process.jl:480
  [3] run
    @ ./process.jl:477 [inlined]
  [4] (::DocumenterVitepress.var"#7#9"{MarkdownVitepress, String})()
    @ DocumenterVitepress ~/data/.julia/packages/DocumenterVitepress/AH5XK/src/writer.jl:186
  [5] cd(f::DocumenterVitepress.var"#7#9"{MarkdownVitepress, String}, dir::String)
    @ Base.Filesystem ./file.jl:112
  [6] render(doc::Documenter.Document, settings::MarkdownVitepress)
    @ DocumenterVitepress ~/data/.julia/packages/DocumenterVitepress/AH5XK/src/writer.jl:180
  [7] runner(#unused#::Type{DocumenterVitepress.MarkdownFormat}, fmt::MarkdownVitepress, doc::Documenter.Document)
    @ DocumenterVitepress ~/data/.julia/packages/DocumenterVitepress/AH5XK/src/DocumenterVitepress.jl:27
  [8] dispatch(::Type{Documenter.FormatSelector}, ::MarkdownVitepress, ::Vararg{Any})
    @ Documenter.Selectors ~/data/.julia/packages/Documenter/pA5Sa/src/utilities/Selectors.jl:170
  [9] render(doc::Documenter.Document)
    @ Documenter ~/data/.julia/packages/Documenter/pA5Sa/src/writers.jl:45
 [10] runner(#unused#::Type{Documenter.Builder.RenderDocument}, doc::Documenter.Document)
    @ Documenter ~/data/.julia/packages/Documenter/pA5Sa/src/builder_pipeline.jl:258
 [11] dispatch(#unused#::Type{Documenter.Builder.DocumentPipeline}, x::Documenter.Document)
    @ Documenter.Selectors ~/data/.julia/packages/Documenter/pA5Sa/src/utilities/Selectors.jl:170
 [12] #84
    @ ~/data/.julia/packages/Documenter/pA5Sa/src/makedocs.jl:248 [inlined]
 [13] withenv(::Documenter.var"#84#86"{Documenter.Document}, ::Pair{String, Nothing}, ::Vararg{Pair{String, Nothing}})
    @ Base ./env.jl:197
 [14] #83
    @ ~/data/.julia/packages/Documenter/pA5Sa/src/makedocs.jl:247 [inlined]
 [15] cd(f::Documenter.var"#83#85"{Documenter.Document}, dir::String)
    @ Base.Filesystem ./file.jl:112
 [16] #makedocs#82
    @ ~/data/.julia/packages/Documenter/pA5Sa/src/makedocs.jl:247 [inlined]

It's a bit annoying to get an issue without a reproducer, but maybe someone here has some idea of how to fix this anyway.

Thanks for your efforts!

asinghvi17 commented 2 months ago

Huh! Yeah we should be using the JLL, but I will look through the code again and see what's going on...

asinghvi17 commented 2 months ago
julia> using NodeJS_20_jll

julia> npm
"/Users/anshul/.julia/artifacts/e972793fde0fa31a7fc77a58fa34e5ebd54e6658/bin/npm"

julia> NodeJS_20_jll.npm |> typeof
String

so this doesn't adjust the PATH appropriately. Looks like an error on the NodeJS_jll end...

asinghvi17 commented 2 months ago

https://github.com/JuliaPackaging/Yggdrasil/pull/8595 should fix this issue, we will have to restrict compat for NodeJS_20_jll to v20.12.2 and above here.

korsbo commented 2 months ago

Horray! Thanks 🥇

asinghvi17 commented 2 months ago

Update: the Yggdrasil PR would have been breaking for users of NodeJS_20_jll, so I opted to use node to set the environment variables in #123.