1. 安装环境
操作系统:Ubuntu16
node版本:v14.15.3
npm版本:6.14.9
2.安装过程
1.先安装libgd
sudo apt-get install libgd-dev
2.再安装node-gd
npm install node-gd
发现报错,似乎是没权限
gyp WARN EACCES current user does not have permission to access the dev dir "/root/.cache/node-gyp/14.15.3"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/xxxx/node_modules/node-gd/.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/xxxx/node_modules/node-gd/.node-gyp"
3.在命令前加上sudo
,继续执行
sudo npm install node-gd
还是报错,猜测可能与node-gyp
有关
> node-gd@2.1.1 install /root/node_modules/node-gd
> node-gyp rebuild
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: socket hang up
gyp ERR! stack at connResetException (internal/errors.js:607:14)
gyp ERR! stack at TLSSocket.socketOnEnd (_http_client.js:493:23)
gyp ERR! stack at TLSSocket.emit (events.js:327:22)
gyp ERR! stack at endReadableNT (internal/streams/readable.js:1327:12)
gyp ERR! stack at processTicksAndRejections (internal/process/task_queues.js:80:21)
gyp ERR! System Linux 4.4.0-170-generic
gyp ERR! command "/usr/local/node-v14.15.3-linux-x64/bin/node" "/usr/local/node-v14.15.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/node_modules/node-gd
gyp ERR! node -v v14.15.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
4.安装node-gyp
npm install -g node-gyp
没有报错
+ node-gyp@7.1.2
updated 1 package in 14.618s
5.再次尝试安装
sudo npm install node-gd
没有报错
+ node-gd@2.1.1
added 102 packages from 148 contributors and audited 102 packages in 35.639s