Cannot install tileserver-gl using npm

1.1k Views Asked by At

I am trying to install tileserver to create raster tiles offline. When i tried to install tileserver using npm, I get the following error:

$ sudo npm install -g tileserver-gl
/usr/local/bin/tileserver-gl -> /usr/local/lib/node_modules/tileserver-gl/src/main.js

> [email protected] install /usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v64 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3/lib/binding'
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/home/ash/.cache/node-gyp/10.16.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3/.node-gyp'
gyp ERR! System Linux 4.4.0-18362-Microsoft
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=/usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3/lib/binding/node-v64-linux-x64" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
gyp ERR! cwd /usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3
gyp ERR! node -v v10.16.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 '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3/lib/binding/node-v64-linux-x64 --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:982:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Linux 4.4.0-18362-Microsoft
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3
node-pre-gyp ERR! node -v v10.16.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
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=/usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/usr/local/lib/node_modules/tileserver-gl/node_modules/sqlite3/lib/binding/node-v64-linux-x64 --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">=6 <7"} (current: {"node":"10.16.0","npm":"6.13.4"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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!     /home/ash/.npm/_logs/2019-12-19T06_26_16_494Z-debug.log

I tried the code below, it says Error: Cannot find module 'graceful-fs'

 $sudo node-gyp rebuild -g --unsafe-perm 

I tried downloading graceful-fs, it still gives the same error.

1

There are 1 best solutions below

0
On

It is an issue with node permissions, try this:

Back up your computer. On the command line, in your home directory, create a directory for global installations:

mkdir ~/.npm-global

Configure npm to use the new directory path:

npm config set prefix '~/.npm-global'

In your preferred text editor, open or create a

~/.profile

file and add this line:

export PATH=~/.npm-global/bin:$PATH

On the command line, update your system variables:

source ~/.profile

To test your new configuration, install a package globally without using sudo