Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm i fails if node-mapnik binaries aren't available for arm/arm64/win-x86 #132

Closed
adamfranco opened this issue Jan 31, 2022 · 15 comments · Fixed by #374
Closed

npm i fails if node-mapnik binaries aren't available for arm/arm64/win-x86 #132

adamfranco opened this issue Jan 31, 2022 · 15 comments · Fixed by #374
Labels
documentation Improvements or additions to documentation

Comments

@adamfranco
Copy link
Collaborator

I'm trying to set up americana on a new M1/arm64 Macbook, but found that installation is failing because the mapnik-node binary doesn't exist for the arm64 architecture.

The x64 binary exists:
https://mapbox-node-binary.s3.amazonaws.com/mapnik/v4.5.8/Release/darwin-x64.tar.gz
but the arm64 binary doesn't exist and triggers a custom build of :
https://mapbox-node-binary.s3.amazonaws.com/mapnik/v4.5.8/Release/darwin-arm64.tar.gz

Upstream issue: mapnik/node-mapnik#945

npm i fails with this error:

npm ERR! code 1
npm ERR! path /Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/lib/binding/mapnik.node --module_name=mapnik --module_path=/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/lib/binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (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.5
npm ERR! node-pre-gyp info using node@16.13.2 | darwin | arm64
npm ERR! node-pre-gyp info check checked for "/Users/afranco/OSM-Dev/openstreetmap-americana/style/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.8/Release/darwin-arm64.tar.gz
npm ERR! 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 
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for mapnik@4.5.8 and node@16.13.2 (node-v93 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.8/Release/darwin-arm64.tar.gz 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.13.2 | darwin | arm64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.13.2 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.8.9 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
npm ERR! gyp info spawn /Applications/Xcode.app/Contents/Developer/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/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   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/common.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/afranco/Library/Caches/node-gyp/16.13.2/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=/Users/afranco/Library/Caches/node-gyp/16.13.2',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/afranco/Library/Caches/node-gyp/16.13.2/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/afranco/OSM-Dev/openstreetmap-americana/style/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   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! /bin/sh: mapnik-config: command not found
npm ERR! gyp: Call to 'mapnik-config --cflags' returned exit status 127 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.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:259:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 21.2.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/lib/binding/mapnik.node" "--module_name=mapnik" "--module_path=/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/lib/binding" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
npm ERR! gyp ERR! cwd /Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik
npm ERR! gyp ERR! node -v v16.13.2
npm ERR! gyp ERR! node-gyp -v v8.4.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 '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/lib/binding/mapnik.node --module_name=mapnik --module_path=/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/lib/binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! node-pre-gyp ERR! System Darwin 21.2.0
npm ERR! node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik
npm ERR! node-pre-gyp ERR! node -v v16.13.2
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.5
npm ERR! node-pre-gyp ERR! not ok

Given the outstanding upstream issue, I'd suggest noting that mapnik might be needed in the installation docs just so other contributors don't have to track down this issue independently. Installing mapnik and all of its dependencies (at least via macports) takes forever, but at least is straight forward.

I'll submit a PR once I confirm that port install mapnik is the trick that allows the rest of the build to work.

@adamfranco adamfranco added the documentation Improvements or additions to documentation label Jan 31, 2022
@Mashin6
Copy link
Contributor

Mashin6 commented Jan 31, 2022

I had the same issue. Solved it by adding this docker image of spritezero to Makefile docker run --platform linux/amd64 -it -e FOLDER=../icons -e THEME=sprite -v ${PWD}:/data dolomate/spritezero

Though I don't know how essential Mapnik is for the sprite sheet generation. Could spritezero be forked, Mapnik removed and would it still run?

@jleedev
Copy link
Collaborator

jleedev commented Jan 31, 2022

Browsing through NPM, https://www.npmjs.com/package/sharp seems to be able to rasterize an SVG and provides binaries for a sufficient number of architectures.

Or this: https://github.com/yisibl/resvg-js

@adamfranco
Copy link
Collaborator Author

It turns out that port install mapnik wasn't sufficient in my case. It's still failing maybe because mapnik-config isn't part of the the mapnik port? 🤔

I also tried to ensure that npm and node were installed with macports and port install python38 to get node-gyp to stay in my ports tree to have better luck finding the mapnik stuff, but so far to no avail:

npm ERR! code 1
npm ERR! path /Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! Failed to execute '/opt/local/bin/node /opt/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/lib/binding/mapnik.node --module_name=mapnik --module_path=/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/lib/binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (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.5
npm ERR! node-pre-gyp info using node@16.13.2 | darwin | arm64
npm ERR! node-pre-gyp info check checked for "/Users/afranco/OSM-Dev/openstreetmap-americana/style/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.8/Release/darwin-arm64.tar.gz
npm ERR! 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 
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for mapnik@4.5.8 and node@16.13.2 (node-v93 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.8/Release/darwin-arm64.tar.gz 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.13.2 | darwin | arm64
npm ERR! gyp info ok 
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.13.2 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.8.12 found at "/opt/local/bin/python3"
npm ERR! gyp info spawn /opt/local/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/opt/local/lib/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   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/common.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/opt/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/afranco/Library/Caches/node-gyp/16.13.2/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=/Users/afranco/Library/Caches/node-gyp/16.13.2',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/opt/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/afranco/Library/Caches/node-gyp/16.13.2/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/afranco/OSM-Dev/openstreetmap-americana/style/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   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! /bin/sh: mapnik-config: command not found
npm ERR! gyp: Call to 'mapnik-config --cflags' returned exit status 127 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.onCpExit (/opt/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:259:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 21.2.0
npm ERR! gyp ERR! command "/opt/local/bin/node" "/opt/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/lib/binding/mapnik.node" "--module_name=mapnik" "--module_path=/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/lib/binding" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
npm ERR! gyp ERR! cwd /Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik
npm ERR! gyp ERR! node -v v16.13.2
npm ERR! gyp ERR! node-gyp -v v8.4.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 '/opt/local/bin/node /opt/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/lib/binding/mapnik.node --module_name=mapnik --module_path=/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik/lib/binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! node-pre-gyp ERR! System Darwin 21.2.0
npm ERR! node-pre-gyp ERR! command "/opt/local/bin/node" "/Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/afranco/OSM-Dev/openstreetmap-americana/style/node_modules/mapnik
npm ERR! node-pre-gyp ERR! node -v v16.13.2
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.5
npm ERR! node-pre-gyp ERR! not ok

Maybe alternate ways of tackling this like @Mashin6 and @jleedev suggest would be better...

@Mashin6 , what other steps did you need to take to get the docker alternative for spritezero working? I'm imagining that installing docker is part of it, but not sure beyond that. ;-)

@Mashin6
Copy link
Contributor

Mashin6 commented Jan 31, 2022

From the start, I did:

git clone https://github.com/ZeLonewolf/openstreetmap-americana.git
cd openstreetmap-americana/style
rm package.json

sudo port install nvm 
source /opt/local/share/nvm/init-nvm.sh
## write into .bashrc: source /opt/local/share/nvm/init-nvm.sh

nvm install 16.13.1
npm -g config set user $USER
npm install browser-sync
npm install prettier


## download and install Docker desktop app from https://www.docker.com/products/docker-desktop
## Launch docker.app

## edit Makefile so sprites section looks like this:
sprites: clean
	mkdir -p sprites
	docker run --platform linux/amd64 -it -e FOLDER=../icons -e THEME=sprite -v ${PWD}:/data dolomate/spritezero

make run

I hope I didn't forget anything.

@ZeLonewolf
Copy link
Owner

Note that xmlstarlet should no longer be needed, now that we've removed the SVG transformation code from when we were importing rebusurance shields.

@Mashin6
Copy link
Contributor

Mashin6 commented Jan 31, 2022

Sweet, crossing that out..

@Mashin6
Copy link
Contributor

Mashin6 commented Jan 31, 2022

@jleedev Looking into spritezero, there are two places Mapnik is used:

  1. generating .png from .svg https://github.com/mapbox/spritezero/blob/80f3027c95ad1ec79335d0f27b1025bbcfee49d1/lib/generate.js#L124
  2. and blending all .png parts to one big picture
    https://github.com/mapbox/spritezero/blob/80f3027c95ad1ec79335d0f27b1025bbcfee49d1/lib/generate.js#L221

If sharp could do both then there would be a way to switch the backend.

@Mashin6
Copy link
Contributor

Mashin6 commented Feb 1, 2022

@adamfranco Also I just realized that x64 binaries should be able to run through rosetta. So a possibility is to install Rosetta and run bash in x64 mode arch -x86_64 $SHELL. Then install x64 version of npm and spritezero.

@adamfranco
Copy link
Collaborator Author

Thanks @Mashin6! that worked for me! Here's the process I used to get npm i working on m1.

First I made a duplicate of Terminal set to open with Rosetta as described here: https://www.courier.com/blog/tips-and-tricks-to-setup-your-apple-m1-for-development/

Then I followed these instructions to install an LTS version of nvm tied to x64: https://gist.github.com/LeZuse/bf838718ff2689c5fc035c5a6825a11c

These commands are run under the Rosetta-Terminal. Note that my global install of node is for arm64, so I'm using nvm to get an x64 version installed temporarily.

[afranco@C02FK09EQ05Q style (main)]$ arch
i386
[afranco@C02FK09EQ05Q style (main)]$ node -e 'console.log(process.arch)'
arm64
[afranco@C02FK09EQ05Q style (main)]$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
[afranco@C02FK09EQ05Q style (main)]$ bash
[afranco@C02FK09EQ05Q style (main)]$ nvm install lts/fermium
[afranco@C02FK09EQ05Q style (main)]$ nvm use lts/fermium
Now using node v14.19.0 (npm v6.14.16)
[afranco@C02FK09EQ05Q style (main)]$ node -e 'console.log(process.arch)'
x64
[afranco@C02FK09EQ05Q style (main)]$ npm i

After this first install which downloads the node-mapnik binaries, it seems like further npm commands in the non-Rosetta amd64 version of npm work just fine.

Removing the dependency might also be a decent option going forward, but this work around seems easy enough to at least get up and running on m1 right now.

@Mashin6
Copy link
Contributor

Mashin6 commented Feb 2, 2022

Awesome!

@Mashin6
Copy link
Contributor

Mashin6 commented Feb 4, 2022

I wanted to avoid standalone install of nvm and this worked for me as well.

Normal Terminal

sudo port install nvm
source /opt/local/share/nvm/init-nvm.sh

Rosetta Terminal

nvm install lts/fermium
nvm use lts/fermium
npm i

Normal Terminal

nvm use lts/fermium
npm start

@zekefarwell
Copy link
Collaborator

I tried running the project natively on Windows, and got the same, or very similar error. Windows users can run on Linux via WSL, but it looks like removing this dependency would be beneficial for more than just those with Apple Silicon Macs.

PS C:\Users\Zeke\sites\openstreetmap-americana\style> npm install
npm WARN deprecated multiline@2.0.0: This was a fun hack, but now we have template literals, so use that instead.
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm notice 
npm notice New minor version of npm available! 8.3.1 -> 8.5.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.5.0
npm notice Run npm install -g npm@8.5.0 to update!
npm notice
npm ERR! code 1
npm ERR! path C:\Users\Zeke\sites\openstreetmap-americana\style\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:\Users\Zeke\sites\openstreetmap-americana\style\node_modules\mapnik\lib\binding\mapnik.node --module_name=mapnik --module_path=C:\Users\Zeke\sites\openstreetmap-americana\style\node_modules\mapnik\lib\binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (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.8
npm ERR! node-pre-gyp info using node@16.14.0 | win32 | x64
npm ERR! node-pre-gyp info check checked for "C:\Users\Zeke\sites\openstreetmap-americana\style\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@16.14.0 (node-v93 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@8.4.1
npm ERR! gyp info using node@16.14.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@8.4.1
npm ERR! gyp info using node@16.14.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.10.2 found at "C:\Python310\python.exe"
npm ERR! gyp http GET https://nodejs.org/download/release/v16.14.0/node-v16.14.0-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.14.0/node-v16.14.0-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v16.14.0/SHASUMS256.txt
npm ERR! gyp http GET https://nodejs.org/download/release/v16.14.0/win-x86/node.lib
npm ERR! gyp http GET https://nodejs.org/download/release/v16.14.0/win-x64/node.lib
npm ERR! gyp http GET https://nodejs.org/download/release/v16.14.0/win-arm64/node.lib
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.14.0/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.14.0/win-x64/node.lib
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.14.0/win-x86/node.lib
npm ERR! gyp http 404 https://nodejs.org/download/release/v16.14.0/win-arm64/node.lib
npm ERR! gyp info find VS using VS2019 (16.11.32126.315) found at:
npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Python310\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:\\Users\\Zeke\\sites\\openstreetmap-americana\\style\\node_modules\\mapnik\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\Zeke\\sites\\openstreetmap-americana\\style\\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\\Zeke\\AppData\\Local\\node-gyp\\Cache\\16.14.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\\Zeke\\AppData\\Local\\node-gyp\\Cache\\16.14.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\\\\Zeke\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.14.0\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\Zeke\\sites\\openstreetmap-americana\\style\\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:\\Users\\Zeke\\sites\\openstreetmap-americana\\style\\node_modules\\mapnik\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
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.onCpExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:259:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19041
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:\\Users\\Zeke\\sites\\openstreetmap-americana\\style\\node_modules\\mapnik\\lib\\binding\\mapnik.node" "--module_name=mapnik" "--module_path=C:\\Users\\Zeke\\sites\\openstreetmap-americana\\style\\node_modules\\mapnik\\lib\\binding" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
npm ERR! gyp ERR! cwd C:\Users\Zeke\sites\openstreetmap-americana\style\node_modules\mapnik
npm ERR! gyp ERR! node -v v16.14.0
npm ERR! gyp ERR! node-gyp -v v8.4.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:\Users\Zeke\sites\openstreetmap-americana\style\node_modules\mapnik\lib\binding\mapnik.node --module_name=mapnik --module_path=C:\Users\Zeke\sites\openstreetmap-americana\style\node_modules\mapnik\lib\binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\Zeke\sites\openstreetmap-americana\style\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1092:16)
npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.19041
npm ERR! node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Zeke\\sites\\openstreetmap-americana\\style\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd C:\Users\Zeke\sites\openstreetmap-americana\style\node_modules\mapnik
npm ERR! node-pre-gyp ERR! node -v v16.14.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.8
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Zeke\AppData\Local\npm-cache\_logs\2022-02-12T03_32_46_248Z-debug-0.log

@ZeLonewolf
Copy link
Owner

Can we confirm whether this is still an issue? If it's only a problem on one specific platform, let's update the issue title to reflect that.

@jleedev
Copy link
Collaborator

jleedev commented Feb 23, 2022

mapnik still doesn't have binaries for linux arm and arm64.

@zekefarwell
Copy link
Collaborator

Sounds like the issue has been confirmed on Linux arm, Mac arm, and Windows x86. The issue is not present on Linux x86 and Mac x86.

@ZeLonewolf ZeLonewolf changed the title npm i fails if node-mapnik binaries aren't available for the current platform npm i fails if node-mapnik binaries aren't available for arm/arm64/win-x86 Feb 23, 2022
jleedev added a commit that referenced this issue Jun 7, 2022
Replace spritezero with the (just-released) [sprites], which uses the
same [shelf-pack] logic but uses [sharp] for SVG rendering, which has
the advantages of:

- Provides [binaries] for several platforms (windows, macos, linux,
  linuxmusl) and architectures (arm64 and x64) - Fixes #132.
- Compiles without a fuss on other platforms (e.g. 32-bit linux arm),
  unlike mapnik which is, shall we say, large.
- Seems to render certain SVGs more correctly than mapnik. I haven't
  prepared a gallery, but there were obvious fixes in  the area of
  antialiasing and downsampling. Of note, mapnik was inflating the
  stroke width in star_state_capital.svg and dot_city (if we liked those,
  we should adjust the stroke width in the actual icon). There are minor
  changes to dimensions due to rounding:

```
$ curl -fs https://zelonewolf.github.io/openstreetmap-americana/sprites/sprite.json | jq -c .shield40_us_oh_tus_salem
{"height":19,"pixelRatio":1,"width":25,"x":283,"y":61}
$ <style/dist/sprites/sprite.json jq -c .shield40_us_oh_tus_salem
{"width":25,"height":20,"x":85,"y":221,"pixelRatio":1}
$ head -n1 style/icons/shield40_us_oh_tus_salem.svg
<svg width="25" height="19.999" version="1.0" xmlns="http://www.w3.org/2000/svg">
```

As a result, the entire sprite sheet looks different, so a comparison is
full of noise, but efforts to align SVGs to a pixel grid can be more
useful now.

[binaries]: https://github.com/lovell/sharp/releases
[shelf-pack]: https://www.npmjs.com/package/@mapbox/shelf-pack
[sharp]: https://www.npmjs.com/package/sharp
[sprites]: https://www.npmjs.com/package/@basemaps/sprites
jleedev added a commit that referenced this issue Jun 7, 2022
Replace spritezero with the (just-released) [sprites], which uses the
same [shelf-pack] logic but uses [sharp] for SVG rendering, which has
the advantages of:

- Provides [binaries] for several platforms (windows, macos, linux,
  linuxmusl) and architectures (arm64 and x64) - Fixes #132.
- Compiles without a fuss on other platforms (e.g. 32-bit linux arm),
  unlike mapnik which is, shall we say, large.
- Seems to render certain SVGs more correctly than mapnik. I haven't
  prepared a gallery, but there were obvious fixes in  the area of
  antialiasing and downsampling. Of note, mapnik was inflating the
  stroke width in star_state_capital.svg and dot_city (if we liked those,
  we should adjust the stroke width in the actual icon). There are minor
  changes to dimensions due to rounding:

```
$ curl -fs https://zelonewolf.github.io/openstreetmap-americana/sprites/sprite.json | jq -c .shield40_us_oh_tus_salem
{"height":19,"pixelRatio":1,"width":25,"x":283,"y":61}
$ <style/dist/sprites/sprite.json jq -c .shield40_us_oh_tus_salem
{"width":25,"height":20,"x":85,"y":221,"pixelRatio":1}
$ head -n1 style/icons/shield40_us_oh_tus_salem.svg
<svg width="25" height="19.999" version="1.0" xmlns="http://www.w3.org/2000/svg">
```

As a result, the entire sprite sheet looks different, so a comparison is
full of noise, but efforts to align SVGs to a pixel grid can be more
useful now.

[binaries]: https://github.com/lovell/sharp/releases
[shelf-pack]: https://www.npmjs.com/package/@mapbox/shelf-pack
[sharp]: https://www.npmjs.com/package/sharp
[sprites]: https://www.npmjs.com/package/@basemaps/sprites
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants