我正在尝试安装切片服务器以离线创建栅格切片。当我尝试使用 npm 安装瓷砖服务器时,出现以下错误:
$ sudo npm install -g tileserver-gl
/usr/local/bin/tileserver-gl -> /usr/local/lib/node_modules/tileserver-gl/src/main.js
> sqlite3@4.1.1 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 sqlite3@4.1.1 and node@10.16.0 (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 tileserver-gl@2.5.0: wanted: {"node":">=6 <7"} (current: {"node":"10.16.0","npm":"6.13.4"})
npm WARN notsup Not compatible with your version of node/npm: tileserver-gl@2.5.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sqlite3@4.1.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3@4.1.1 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
我尝试了下面的代码,它说Error: Cannot find module 'graceful-fs'
$sudo node-gyp rebuild -g --unsafe-perm
我尝试下载优雅的 fs,它仍然给出相同的错误。
这是节点权限的问题,请尝试以下操作:
备份您的计算机。在命令行的主目录中,为全局安装创建一个目录:
mkdir ~/.npm-global
配置 npm 以使用新的目录路径:
npm config set prefix '~/.npm-global'
在您首选的文本编辑器中,打开或创建一个
~/.profile
文件并添加此行:
export PATH=~/.npm-global/bin:$PATH
在命令行上,更新系统变量:
source ~/.profile
要测试新配置,请在不使用 sudo 的情况下全局安装软件包