mapbox / spritezero

small opinionated sprites
Other
171 stars 62 forks source link

Error installing spritezero #84

Open eduboxgithub opened 4 years ago

eduboxgithub commented 4 years ago

I was using spritezero-cli but I think the CLI version is not up to date and have very old dependencies.. node 8 and a previues version of spritezero.

I'm trying to install spritezero and run it via a node script but I get this error:

node-pre-gyp WARN Using needle for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/mapnik/v4.4.0/node-v72-win32-x64-Release.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for mapnik@4.4.0 and node@12.14.0 (node-v72 ABI, unknown) (falling back to source compile with node-gyp) 
'mapnik-config' is not recognized as an internal or external command,
operable program or batch file.
gyp: Call to 'mapnik-config --ldflags' returned exit status 1 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.onCpExit (C:\Users\hsantos\AppData\Roaming\nvm\v12.14.0\node_modules\npm\node_modules\node-gyp\lib\configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\hsantos\\AppData\\Roaming\\nvm\\v12.14.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configu
re" "--fallback-to-build" "--module=D:\\_DESKTOP\\Sinaletica\\node_modules\\mapnik\\lib\\binding\\mapnik.node" "--module_name=mapnik" "--module_path=D:\\_DESKTOP\\Sinaletica\\node_modules\\mapnik\\lib\\binding" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72" "--msvs_version=2017"
gyp ERR! cwd D:\_DESKTOP\Sinaletica\node_modules\mapnik
gyp ERR! node -v v12.14.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\hsantos\AppData\Roaming\nvm\v12.14.0\node_modules\npm\node_modules\node-gyp\bin\node-g
yp.js configure --fallback-to-build --module=D:\_DESKTOP\Sinaletica\node_modules\mapnik\lib\binding\mapnik.node --module_name=mapnik --module_path=D:\_DESKTOP\Sinaletica\node_modules\mapnik\lib\binding --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72 --msvs_version=2017' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (D:\_DESKTOP\Sinaletica\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Windows_NT 10.0.18363
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\_DESKTOP\\Sinaletica\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd D:\_DESKTOP\Sinaletica\node_modules\mapnik
node-pre-gyp ERR! node -v v12.14.0
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\hsantos\AppData\Roaming\nvm\v12.14.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=D:\_DESKTOP\Sinaletica\node
_modules\mapnik\lib\binding\mapnik.node --module_name=mapnik --module_path=D:\_DESKTOP\Sinaletica\node_modules\mapnik\lib\binding --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72 --msvs_version=2017' (1)
npm WARN assets-sinaletica@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mapnik@4.4.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mapnik@4.4.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\hsantos\AppData\Roaming\npm-cache\_logs\2020-07-03T12_22_46_075Z-debug.log

I have visual studio 2019 community edition installed with the C++ libs.

Can someone help me out installing spritezero?

candu commented 4 years ago

Same here - it's failing for me with:

node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/mapnik/v3.6.2/node-v72-linux-x64-Release.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for mapnik@3.6.2 and node@12.16.3 (node-v72 ABI) (falling back to source compile with node-gyp) 
node-pre-gyp ERR! Tried to download(undefined): https://mapbox-node-binary.s3.amazonaws.com/mapnik/v3.6.2/node-v72-linux-x64-Release.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for mapnik@3.6.2 and node@12.16.3 (node-v72 ABI) (falling back to source compile with node-gyp)

When attempting to visit the AWS link directly, I get:

image

candu commented 4 years ago

Managed it with a really old version of node (using nvm to manage node versions):

nvm install 6.17.1
nvm use 6.17.1
npm install -g @mapbox/spritezero-cli

and at this point you should be able to spritezero [output] [input].

In the process, I realized that this is actually an upstream issue with mapnik - they host prebuilt C++ modules on AWS, but haven't built these for node since v6 (!)

I was able to build mapnik.node, but have no idea how to "link" against it when installing @mapbox/spritezero-cli. (Also very confused that mapnik's node bindings apparently go to version 4.4.0, but their documentation only goes to version 3.6.)

eduboxgithub commented 4 years ago

It also works with node version 8.17... Any other version above this one will reproduce the initial error...

erdmann040 commented 3 years ago

Had the same problem on Linux (fedora 34). But the workaround with this prehistoric node version worked.

jampueroc commented 1 year ago

any update on this?

I tried an older version of node but it gave me this error:

/myProject/node_modules/@mapbox/spritezero/lib/generate.js:136
                      ...img,
                      ^^^

SyntaxError: Unexpected token ...
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/myProject/node_modules/@mapbox/spritezero/index.js:1:80)

And new node version still gives me the error, I try with node 6 and 16

EDIT: Using node 10.24.1 It's works.

nmcdtu commented 6 months ago

I could install @mapbox/spritezero-cli on my nodejs v18.16.0

$ node -v
v18.16.0

with the following:

npm -g install mapnik
npm -g install @mapbox/spritezero

Here are my packages:

$ npm list -g

├── @mapbox/mbtiles@0.12.1
├── @mapbox/mbview@5.1.0
├── @mapbox/spritezero@8.0.3
├── @mapbox/tilelive@6.1.1
├── corepack@0.17.0
├── eslint@8.53.0
├── json-stable-stringify@1.1.1
├── mapnik@4.5.9
├── mbgl@1.3.8
├── npm@9.5.1
├── requireg@0.2.2
├── tilelive-modules@0.4.2
├── tilelive-pgquery@1.5.0
└── tileserver-gl@4.6.5
jutaz commented 1 month ago

Here's one possible solution - this is a fork of the library with a different engine which support any node version from 14.15: https://www.npmjs.com/package/@jutaz/spritezero

Can install it simply by running: npm i @jutaz/spritezero

Happy to answer any questions about it, if there are any.