openzim / mwoffliner

Mediawiki scraper: all your wiki articles in one highly compressed ZIM file
https://www.npmjs.com/package/mwoffliner
GNU General Public License v3.0
293 stars 74 forks source link

Impossible to install on ubuntu 22.04 #2064

Closed LAfricain closed 4 months ago

LAfricain commented 4 months ago

I try to install mwoffline on ubuntu 22.04, but I have this issue:

npm warn deprecated swig-templates@2.0.3: unmaintained
npm error code 7
npm error path /home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/@openzim/libzim
npm error command failed
npm error command sh -c npm run download && node-gyp rebuild -v && npm run bundle
npm error > @openzim/libzim@2.4.4 download
npm error > node ./download-libzim.js
npm error
npm error Downloading Libzim from:  http://download.openzim.org/release/libzim/libzim_linux-x86_64-6.3.2.tar.gz
npm error Running Extract: [tar --strip-components 1 -xf ./download/libzim_linux-x86_64-6.3.2.tar.gz -C ./download]
npm error Successfully downloaded and extracted file
npm error gyp info it worked if it ends with ok
npm error gyp verb cli [
npm error gyp verb cli   '/home/cyrille/.nvm/versions/node/v22.5.1/bin/node',
npm error gyp verb cli   '/home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/.bin/node-gyp',
npm error gyp verb cli   'rebuild',
npm error gyp verb cli   '-v'
npm error gyp verb cli ]
npm error gyp info using node-gyp@6.1.0
npm error gyp info using node@22.5.1 | linux | x64
npm error gyp verb command rebuild []
npm error gyp verb command clean []
npm error gyp verb clean removing "build" directory
npm error gyp verb command configure []
npm error gyp verb find Python Python is not set from command line or npm configuration
npm error gyp verb find Python Python is not set from environment variable PYTHON
npm error gyp verb find Python checking if "python3" can be used
npm error gyp verb find Python - executing "python3" to get executable path
npm error (node:316901) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
npm error (Use `node --trace-deprecation ...` to show where the warning was created)
npm error gyp verb find Python - executable path is "/usr/bin/python3"
npm error gyp verb find Python - executing "/usr/bin/python3" to get version
npm error gyp verb find Python - version is "3.10.12"
npm error gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
npm error gyp verb get node dir no --target version specified, falling back to host node version: 22.5.1
npm error gyp verb command install [ '22.5.1' ]
npm error gyp verb install input version string "22.5.1"
npm error gyp verb install installing version: 22.5.1
npm error gyp verb install --ensure was passed, so won't reinstall if already installed
npm error (node:316901) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
npm error gyp verb install version is already installed, need to check "installVersion"
npm error gyp verb got "installVersion" 9
npm error gyp verb needs "installVersion" 9
npm error gyp verb install version is good
npm error gyp verb get node dir target node version installed: 22.5.1
npm error gyp verb build dir attempting to create "build" dir: /home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/@openzim/libzim/build
npm error gyp verb build dir "build" dir needed to be created? /home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/@openzim/libzim/build
npm error gyp verb build/config.gypi creating config file
npm error gyp ERR! UNCAUGHT EXCEPTION 
npm error gyp ERR! stack TypeError: Cannot assign to read only property 'cflags' of object '#<Object>'
npm error gyp ERR! stack     at createConfigFile (/home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/node-gyp/lib/configure.js:118:21)
npm error gyp ERR! stack     at /home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/node-gyp/lib/configure.js:85:9
npm error gyp ERR! stack     at /home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/node-gyp/node_modules/mkdirp/index.js:30:20
npm error gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:187:23)
npm error gyp ERR! System Linux 5.19.0-35-generic
npm error gyp ERR! command "/home/cyrille/.nvm/versions/node/v22.5.1/bin/node" "/home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/.bin/node-gyp" "rebuild" "-v"
npm error gyp ERR! cwd /home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/@openzim/libzim
npm error gyp ERR! node -v v22.5.1
npm error gyp ERR! node-gyp -v v6.1.0
npm error gyp ERR! This is a bug in `node-gyp`.
npm error gyp ERR! Try to update node-gyp and file an Issue if it does not help:
npm error gyp ERR!     <https://github.com/nodejs/node-gyp/issues>
npm error A complete log of this run can be found in: /home/cyrille/.npm/_logs/2024-07-20T17_55_45_726Z-debug-0.log
kelson42 commented 4 months ago

@LAfricain MWoffliner works only with Node.js 18. I recommend to use the Docker image.

LAfricain commented 4 months ago
node -v
v22.5.1

I followed the instruction of the readme.

kelson42 commented 4 months ago

We should probably update package.json to specifically require only nodejs18 as long as we don't use latest node-libzim

LAfricain commented 4 months ago

Ok but for now what should I do? I followed this instruction: https://nodejs.org/en/download/current/

kelson42 commented 4 months ago

https://stackoverflow.com/questions/45826599/how-can-i-require-a-package-only-if-the-version-of-node-is-old-enough

LAfricain commented 4 months ago

I need more help, where is the file package.json I have to change? I ran the command npm install node@18.0.0 without modifying the package.json and node -v is still v22.5.1

LAfricain commented 4 months ago

I solved my problem doing nvm install 18 Now I have to learn how to use it...

LAfricain commented 4 months ago

very strange. This morning It tried to run mwoffliner, and the terminal said commande introuvable. Then I wanted to reinstall it, I had the same problem as yesterday with node 22!!

npm warn deprecated swig-templates@2.0.3: unmaintained
npm error code 7
npm error path /home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/@openzim/libzim
npm error command failed
npm error command sh -c npm run download && node-gyp rebuild -v && npm run bundle
npm error > @openzim/libzim@2.4.4 download
npm error > node ./download-libzim.js
npm error
npm error Downloading Libzim from:  http://download.openzim.org/release/libzim/libzim_linux-x86_64-6.3.2.tar.gz
npm error Running Extract: [tar --strip-components 1 -xf ./download/libzim_linux-x86_64-6.3.2.tar.gz -C ./download]
npm error Successfully downloaded and extracted file
npm error gyp info it worked if it ends with ok
npm error gyp verb cli [
npm error gyp verb cli   '/home/cyrille/.nvm/versions/node/v22.5.1/bin/node',
npm error gyp verb cli   '/home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/.bin/node-gyp',
npm error gyp verb cli   'rebuild',
npm error gyp verb cli   '-v'
npm error gyp verb cli ]
npm error gyp info using node-gyp@6.1.0
npm error gyp info using node@22.5.1 | linux | x64
npm error gyp verb command rebuild []
npm error gyp verb command clean []
npm error gyp verb clean removing "build" directory
npm error gyp verb command configure []
npm error gyp verb find Python Python is not set from command line or npm configuration
npm error gyp verb find Python Python is not set from environment variable PYTHON
npm error gyp verb find Python checking if "python3" can be used
npm error gyp verb find Python - executing "python3" to get executable path
npm error (node:31477) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
npm error (Use `node --trace-deprecation ...` to show where the warning was created)
npm error gyp verb find Python - executable path is "/usr/bin/python3"
npm error gyp verb find Python - executing "/usr/bin/python3" to get version
npm error gyp verb find Python - version is "3.10.12"
npm error gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
npm error gyp verb get node dir no --target version specified, falling back to host node version: 22.5.1
npm error gyp verb command install [ '22.5.1' ]
npm error gyp verb install input version string "22.5.1"
npm error gyp verb install installing version: 22.5.1
npm error gyp verb install --ensure was passed, so won't reinstall if already installed
npm error (node:31477) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
npm error gyp verb install version is already installed, need to check "installVersion"
npm error gyp verb got "installVersion" 9
npm error gyp verb needs "installVersion" 9
npm error gyp verb install version is good
npm error gyp verb get node dir target node version installed: 22.5.1
npm error gyp verb build dir attempting to create "build" dir: /home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/@openzim/libzim/build
npm error gyp verb build dir "build" dir needed to be created? /home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/@openzim/libzim/build
npm error gyp verb build/config.gypi creating config file
npm error gyp ERR! UNCAUGHT EXCEPTION 
npm error gyp ERR! stack TypeError: Cannot assign to read only property 'cflags' of object '#<Object>'
npm error gyp ERR! stack     at createConfigFile (/home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/node-gyp/lib/configure.js:118:21)
npm error gyp ERR! stack     at /home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/node-gyp/lib/configure.js:85:9
npm error gyp ERR! stack     at /home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/node-gyp/node_modules/mkdirp/index.js:30:20
npm error gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:187:23)
npm error gyp ERR! System Linux 5.19.0-35-generic
npm error gyp ERR! command "/home/cyrille/.nvm/versions/node/v22.5.1/bin/node" "/home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/.bin/node-gyp" "rebuild" "-v"
npm error gyp ERR! cwd /home/cyrille/.nvm/versions/node/v22.5.1/lib/node_modules/mwoffliner/node_modules/@openzim/libzim
npm error gyp ERR! node -v v22.5.1
npm error gyp ERR! node-gyp -v v6.1.0
npm error gyp ERR! This is a bug in `node-gyp`.
npm error gyp ERR! Try to update node-gyp and file an Issue if it does not help:
npm error gyp ERR!     <https://github.com/nodejs/node-gyp/issues>
npm error A complete log of this run can be found in: /home/cyrille/.npm/_logs/2024-07-21T08_54_46_934Z-debug-0.log

I had to reinstall node 18!! How to make it work once and for all. How to uninstall completely node 22?

audiodude commented 4 months ago

I believe with nvm you have to specify which version of node to use with individual projects, or otherwise specify it globally. You probably switched to node 18 when you installed it the other day, but didn't realize you had switched back to node 22 when you went to install/run a second time.

Please consult nvm docs here: https://github.com/nvm-sh/nvm?tab=readme-ov-file#usage