mapnik / node-mapnik

Bindings to mapnik for node.js
http://mapnik.org/documentation/node-mapnik
BSD 3-Clause "New" or "Revised" License
531 stars 165 forks source link

Cannot npm install mapnik #992

Closed mlptownsend closed 5 months ago

mlptownsend commented 8 months ago

I have the latest LTS node v20.11.0, installed python, the node installer checkbox for C++ build tools, so nothing should be missing dependency-wise. But running npm install mapnik is failing, and the error indicates that there's a zip file it can't download from S3. Did the file get deleted/moved/ACL changed?

403 Forbidden on https://mapbox-node-binary.s3.amazonaws.com/mapnik/v4.5.9/Release/win32-x64.tar.gz

PS C:\temp\express> npm install mapnik
npm ERR! code 1
npm ERR! path C:\temp\express\node_modules\mapnik
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build
npm ERR! Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\temp\express\node_modules\mapnik\lib\binding\mapnik.node --module_name=mapnik --module_path=C:\temp\express\node_modules\mapnik\lib\binding --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v115' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@1.0.11
npm ERR! node-pre-gyp info using node@20.11.0 | win32 | x64
npm ERR! node-pre-gyp info check checked for "C:\temp\express\node_modules\mapnik\lib\binding\mapnik.node" (not found)
npm ERR! node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/mapnik/v4.5.9/Release/win32-x64.tar.gz
npm ERR! node-pre-gyp ERR! install response status 403 Forbidden on https://mapbox-node-binary.s3.amazonaws.com/mapnik/v4.5.9/Release/win32-x64.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for mapnik@4.5.9 and node@20.11.0 (node-v115 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error response status 403 Forbidden on https://mapbox-node-binary.s3.amazonaws.com/mapnik/v4.5.9/Release/win32-x64.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@20.11.0 | win32 | x64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@20.11.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.12.1 found at "C:\Python312\python.exe"
npm ERR! gyp http GET https://nodejs.org/download/release/v20.11.0/node-v20.11.0-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v20.11.0/node-v20.11.0-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v20.11.0/SHASUMS256.txt
npm ERR! gyp http GET https://nodejs.org/download/release/v20.11.0/win-x64/node.lib
npm ERR! gyp http 200 https://nodejs.org/download/release/v20.11.0/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v20.11.0/win-x64/node.lib
npm ERR! gyp info find VS using VS2022 (17.8.34408.163) found at:
npm ERR! gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Professional"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Python312\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args 'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'msvs',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\\temp\\express\\node_modules\\mapnik\\build\\config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\\temp\\express\\node_modules\\mapnik\\common.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args 'C:\\Users\\peter\\AppData\\Local\\node-gyp\\Cache\\20.11.0\\include\\node\\common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=C:\\Users\\peter\\AppData\\Local\\node-gyp\\Cache\\20.11.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\peter\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\20.11.0\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=C:\\temp\\express\\node_modules\\mapnik',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'C:\\temp\\express\\node_modules\\mapnik\\build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Could not find platform independent libraries <prefix>
npm ERR! <string>:129: SyntaxWarning: invalid escape sequence '\$'
npm ERR! 'mapnik-config' is not recognized as an internal or external command,
npm ERR! operable program or batch file.
npm ERR! gyp: Call to 'mapnik-config --includes' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:271:18)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:518:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\temp\\express\\node_modules\\mapnik\\lib\\binding\\mapnik.node" "--module_name=mapnik" "--module_path=C:\\temp\\express\\node_modules\\mapnik\\lib\\binding" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v115"
npm ERR! gyp ERR! cwd C:\temp\express\node_modules\mapnik
npm ERR! gyp ERR! node -v v20.11.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\temp\express\node_modules\mapnik\lib\binding\mapnik.node --module_name=mapnik --module_path=C:\temp\express\node_modules\mapnik\lib\binding --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v115' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\temp\express\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:518:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1105:16)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.22621
npm ERR! node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\temp\\express\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd C:\temp\express\node_modules\mapnik
npm ERR! node-pre-gyp ERR! node -v v20.11.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.11
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in: C:\Users\peter\AppData\Local\npm-cache\_logs\2024-01-16T21_00_58_512Z-debug-0.log

2024-01-16T21_00_58_512Z-debug-0.log

diogo-garcia commented 7 months ago

Strange, I had no problem installing on debian 12 few days ago... Maybe the node version? I've just installed it and it's an inferior version than yours...

Here is what Ive got:

node --version v18.19.0

cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12" VERSION="12 (bookworm)" VERSION_CODENAME=bookworm ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"

npm -version 9.2.0

npm list mapnik mapnik_nodejs@1.0.0 /root/mapnik_nodejs └── mapnik@4.5.9

simongroom commented 5 months ago

I had the same issue install on Mac OS Sonoma (14.4.1 (23E224)) using Node 20. I tried each major node version (18,16,14) and 14 was the only version that installed successfully for me. I am gonna bump my node version back up, hopefully things work as expected. Would be nice to get some visibility and explanation on this - is this still a maintained project?

artemp commented 5 months ago

@simongroom - you mentioned macOS 14.4.1 but is it x86_64 or arm64?

FYI, there is no binaries in 4.5.9 for arm64 (macbooks M1,M2,M3 etc). Binaries for arm64 are planned to be included in 4.6.0 release which will use mapnik 4.x.x as a core.

uname -m

??

Could you paste what error(s) you're seeing when running npm install mapnik ?

simongroom commented 5 months ago

@simongroom - you mentioned macOS 14.4.1 but is it x86_64 or arm64?

FYI, there is no binaries in 4.5.9 for arm64 (macbooks M1,M2,M3 etc). Binaries for arm64 are planned to be included in 4.6.0 release which will use mapnik 4.x.x as a core.

uname -m

??

Could you paste what error(s) you're seeing when running npm install mapnik ?

@artemp thanks for the response!! I'm on arm64.. currently using node 20.

and this is the output when attempting to pnpm install (same result using npm install):


node_modules/.pnpm/mapnik@4.5.8/node_modules/mapnik: Running install script, failed in 2.5s
.../mapnik@4.5.8/node_modules/mapnik install$ node-pre-gyp install --fallback-to-build
│ node-pre-gyp info it worked if it ends with ok
│ node-pre-gyp info using node-pre-gyp@1.0.11
│ node-pre-gyp info using node@20.12.2 | darwin | arm64
│ node-pre-gyp info check checked for "/Users/simon.groom/Code/geopointe-api/node_modules/.pnpm/mapnik@4.5.8/node_modules/mapnik/lib/binding/mapnik.node" (not found)
│ node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/mapnik/v4.5.8/Release/darwin-arm64.tar.gz
│ node-pre-gyp ERR! install response status 403 Forbidden on https://mapbox-node-binary.s3.amazonaws.com/mapnik/v4.5.8/Release/darwin-arm64.tar.gz
│ node-pre-gyp WARN Pre-built binaries not installable for mapnik@4.5.8 and node@20.12.2 (node-v115 ABI, unknown) (falling back to source compile with node-gyp)
│ node-pre-gyp WARN Hit error response status 403 Forbidden on https://mapbox-node-binary.s3.amazonaws.com/mapnik/v4.5.8/Release/darwin-arm64.tar.gz
│ gyp info it worked if it ends with ok
│ gyp info using node-gyp@10.0.1
│ gyp info using node@20.12.2 | darwin | arm64
│ gyp info ok
│ gyp info it worked if it ends with ok
│ gyp info using node-gyp@10.0.1
│ gyp info using node@20.12.2 | darwin | arm64
│ gyp info find Python using Python version 3.12.3 found at "/Library/Frameworks/Python.framework/Versions/3.12/bin/python3"
│ gyp http GET https://nodejs.org/download/release/v20.12.2/node-v20.12.2-headers.tar.gz
│ gyp http 200 https://nodejs.org/download/release/v20.12.2/node-v20.12.2-headers.tar.gz
│ gyp http GET https://nodejs.org/download/release/v20.12.2/SHASUMS256.txt
│ gyp http 200 https://nodejs.org/download/release/v20.12.2/SHASUMS256.txt
│ gyp info spawn /Library/Frameworks/Python.framework/Versions/3.12/bin/python3
│ gyp info spawn args [
│ gyp info spawn args '/Users/simon.groom/Library/pnpm/nodejs/20.12.2/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
│ gyp info spawn args 'binding.gyp',
│ gyp info spawn args '-f',
│ gyp info spawn args 'make',
│ gyp info spawn args '-I',
│ gyp info spawn args '/Users/simon.groom/Code/geopointe-api/node_modules/.pnpm/mapnik@4.5.8/node_modules/mapnik/build/config.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/Users/simon.groom/Code/geopointe-api/node_modules/.pnpm/mapnik@4.5.8/node_modules/mapnik/common.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/Users/simon.groom/Library/pnpm/nodejs/20.12.2/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/Users/simon.groom/Library/Caches/node-gyp/20.12.2/include/node/common.gypi',
│ gyp info spawn args '-Dlibrary=shared_library',
│ gyp info spawn args '-Dvisibility=default',
│ gyp info spawn args '-Dnode_root_dir=/Users/simon.groom/Library/Caches/node-gyp/20.12.2',
│ gyp info spawn args '-Dnode_gyp_dir=/Users/simon.groom/Library/pnpm/nodejs/20.12.2/lib/node_modules/npm/node_modules/node-gyp',
│ gyp info spawn args '-Dnode_lib_file=/Users/simon.groom/Library/Caches/node-gyp/20.12.2/<(target_arch)/node.lib',
│ gyp info spawn args '-Dmodule_root_dir=/Users/simon.groom/Code/geopointe-api/node_modules/.pnpm/mapnik@4.5.8/node_modules/mapnik',
│ gyp info spawn args '-Dnode_engine=v8',
│ gyp info spawn args '--depth=.',
│ gyp info spawn args '--no-parallel',
│ gyp info spawn args '--generator-output',
│ gyp info spawn args 'build',
│ gyp info spawn args '-Goutput_dir=.'
│ gyp info spawn args ]
│ <string>:129: SyntaxWarning: invalid escape sequence '\$'
│ /bin/sh: mapnik-config: command not found
│ gyp: Call to 'mapnik-config --cflags' returned exit status 127 while in binding.gyp. while trying to load binding.gyp
│ gyp ERR! configure error
│ gyp ERR! stack Error: `gyp` failed with exit code: 1
│ gyp ERR! stack at ChildProcess.<anonymous> (/Users/simon.groom/Library/pnpm/nodejs/20.12.2/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:271:18)
│ gyp ERR! stack at ChildProcess.emit (node:events:518:28)
│ gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
│ gyp ERR! System Darwin 23.4.0
│ gyp ERR! command "/Users/simon.groom/Library/pnpm/nodejs/20.12.2/bin/node" "/Users/simon.groom/Library/pnpm/nodejs/20.12.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fal…
│ gyp ERR! cwd /Users/simon.groom/Code/geopointe-api/node_modules/.pnpm/mapnik@4.5.8/node_modules/mapnik
│ gyp ERR! node -v v20.12.2
│ gyp ERR! node-gyp -v v10.0.1
│ gyp ERR! not ok
│ node-pre-gyp ERR! build error
│ node-pre-gyp ERR! stack Error: Failed to execute '/Users/simon.groom/Library/pnpm/nodejs/20.12.2/bin/node /Users/simon.groom/Library/pnpm/nodejs/20.12.2/lib/node_modules/npm/node_modules/node-gyp/bin/n…
│ node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/simon.groom/Code/geopointe-api/node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
│ node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:518:28)
│ node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1105:16)
│ node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
│ node-pre-gyp ERR! System Darwin 23.4.0
│ node-pre-gyp ERR! command "/Users/simon.groom/Library/pnpm/nodejs/20.12.2/bin/node" "/Users/simon.groom/Code/geopointe-api/node_modules/.pnpm/@mapbox+node-pre-gyp@1.0.11/node_modules/@mapbox/node-pre-g…
│ node-pre-gyp ERR! cwd /Users/simon.groom/Code/geopointe-api/node_modules/.pnpm/mapnik@4.5.8/node_modules/mapnik
│ node-pre-gyp ERR! node -v v20.12.2
│ node-pre-gyp ERR! node-pre-gyp -v v1.0.11
│ node-pre-gyp ERR! not ok
│ Failed to execute '/Users/simon.groom/Library/pnpm/nodejs/20.12.2/bin/node /Users/simon.groom/Library/pnpm/nodejs/20.12.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback…
└─ Failed in 2.5s at /Users/simon.groom/Code/geopointe-api/node_modules/.pnpm/mapnik@4.5.8/node_modules/mapnik
node_modules/.pnpm/nodemon@2.0.7/node_modules/nodemon: Running postinstall script, done in 147ms```
artemp commented 5 months ago

@simongroom As I mentioned above, npm install is attempting to download https://mapbox-node-binary.s3.amazonaws.com/mapnik/v4.5.8/Release/darwin-arm64.tar.gz which doesn't exist. There are currently no binaries for arm64.

You have two options -

  1. Compile mapnik and node-mapnik yourself
  2. Wait for node-mapnik v4.6.0
simongroom commented 5 months ago

@artemp ok thank you. this makes sense.

artemp commented 5 months ago

@simongroom there is a third option you could try

3. run npm install on Intel mac, then copy install directory including

~~node_modules~~
~~package-lock.json~~
~~package.json~~

to your arm64 Mac and it should just work because of pre-built support for x86_64 (at least in M2). Not ideal but might be a work around for the time being PS. you will need to install Rosetta -> https://support.apple.com/en-us/102527~~

artemp commented 5 months ago

@simongroom ~there is a third option you could try~

~3. run npm install on Intel mac, then copy install directory including~

~~node_modules~~
~~package-lock.json~~
~~package.json~~

~to your arm64 Mac and it should just work because of pre-built support for x86_64 (at least in M2). Not ideal but might be a work around for the time being~ PS. you will need to install Rosetta -> https://support.apple.com/en-us/102527~~

I've tried and it didn't work for me

bash-3.2$ ./node_modules/.bin/mapnik-inspect.js ~/projects/mapnik-consulting/mapnik-package-builder/mapnik/cairo-demo.svg > cairo-demo.png 
node:internal/modules/cjs/loader:1465
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: dlopen(/private/tmp/mapnik/node_modules/mapnik/lib/binding/mapnik.node, 0x0001): tried: '/private/tmp/mapnik/node_modules/mapnik/lib/binding/mapnik.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/private/tmp/mapnik/node_modules/mapnik/lib/binding/mapnik.node' (no such file), '/private/tmp/mapnik/node_modules/mapnik/lib/binding/mapnik.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
    at Module._extensions..node (node:internal/modules/cjs/loader:1465:18)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/private/tmp/mapnik/node_modules/mapnik/lib/mapnik.js:31:15)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v20.12.1
simongroom commented 5 months ago

thanks for trying @artemp I got this running inside a docker container for now, which is a viable workaround for the time being

simongroom commented 5 months ago

thanks for trying @artemp I got this running inside a docker container for now, which is a viable workaround for the time being

as an update - I got this building in a docker container, but when I run it I am getting an error related to rosetta: Rosetta error: could not find free space for allocation size. Not sure if this will be fixed by the new mapnik-node version (seems unlikely) - but when do you envisage the new version will be available @artemp ?

simongroom commented 5 months ago

circling back to my issue - I now have everything working in a docker container. My apparent prerequisites for the Dockerfile are: 1) change the docker image I was using: FROM --platform=linux/amd64 ubuntu:20.04 not from node:20-alpine or node:20-bookworm 2) then install node 18 and other deps via curl:

RUN apt-get install -y curl
RUN apt-get install -y imagemagick=8:6.*
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install nodejs -y

posting here if anyone else ever finds there way to this.