如何解决 NPM 安装错误?
How to resolve an NPM install error?
我在将网站从 Cloud9 迁移到 DigitalOcean 时遇到问题。
大多数组件似乎已经安装(尽管找不到 ase-tools 和 node-gd),但有一些组件不起作用,我在安装时遇到这些错误。
root@lospec:~/lospec# npm install
npm WARN deprecated minimatch@1.0.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN prefer global node-gyp@3.3.1 should be installed with -g
> node-gd@1.4.0 install /root/lospec/node_modules/node-gd
> node-gyp rebuild
./util.sh: 1: ./util.sh: pkg-config: not found
gyp: Call to './util.sh png16' returned exit status 0 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 (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-63-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/lospec/node_modules/node-gd
gyp ERR! node -v v6.10.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! Linux 4.4.0-63-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.10.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! node-gd@1.4.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-gd@1.4.0 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-gd package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-gd
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls node-gd
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/lospec/npm-debug.log
我无法确定真正导致错误的原因。我认为是 node-gd、node-gyp、pkg-config?
这是我的 package.json:http://pastebin.com/raw/saykdjT2
pkg-config
不是 Node 相关的模块。它是一个系统级构建工具,被许多低级包用作构建过程的一部分。但是,它被一些包含本机(例如 C 语言)代码组件的 NPM 模块使用,因此可以构建它们。 node-gd
有这样的要求,并且在他们的文档 README 中列出了特定于平台的依赖项安装要求:
https://github.com/y-a-v-a/node-gd
在尝试在该系统上安装 node-gd
之前,您需要安装此依赖项。
在您的机器上使用需要本机构建 (c++) 的 npm 包时,这些类型的错误很常见。包 node-gyp
是为您的环境构建本机依赖项的东西。我猜你可能需要在那台机器上 gcc
、python 2.7
和 make
。
有关详细信息,请参阅 node-gyp dependencies。
更新
根据 https://www.digitalocean.com/community/questions/node-gyp-rebuild-fails-on-install,您可以尝试以下操作:
sudo npm install -g node-gyp@latest
sudo npm explore -g npm -- npm i node-gyp@latest
如果这些不起作用,它表示可能删除应用程序并重新推送它可能会修复它。
我在将网站从 Cloud9 迁移到 DigitalOcean 时遇到问题。
大多数组件似乎已经安装(尽管找不到 ase-tools 和 node-gd),但有一些组件不起作用,我在安装时遇到这些错误。
root@lospec:~/lospec# npm install
npm WARN deprecated minimatch@1.0.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN prefer global node-gyp@3.3.1 should be installed with -g
> node-gd@1.4.0 install /root/lospec/node_modules/node-gd
> node-gyp rebuild
./util.sh: 1: ./util.sh: pkg-config: not found
gyp: Call to './util.sh png16' returned exit status 0 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 (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-63-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/lospec/node_modules/node-gd
gyp ERR! node -v v6.10.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! Linux 4.4.0-63-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.10.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! node-gd@1.4.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-gd@1.4.0 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-gd package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-gd
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls node-gd
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/lospec/npm-debug.log
我无法确定真正导致错误的原因。我认为是 node-gd、node-gyp、pkg-config?
这是我的 package.json:http://pastebin.com/raw/saykdjT2
pkg-config
不是 Node 相关的模块。它是一个系统级构建工具,被许多低级包用作构建过程的一部分。但是,它被一些包含本机(例如 C 语言)代码组件的 NPM 模块使用,因此可以构建它们。 node-gd
有这样的要求,并且在他们的文档 README 中列出了特定于平台的依赖项安装要求:
https://github.com/y-a-v-a/node-gd
在尝试在该系统上安装 node-gd
之前,您需要安装此依赖项。
在您的机器上使用需要本机构建 (c++) 的 npm 包时,这些类型的错误很常见。包 node-gyp
是为您的环境构建本机依赖项的东西。我猜你可能需要在那台机器上 gcc
、python 2.7
和 make
。
有关详细信息,请参阅 node-gyp dependencies。
更新 根据 https://www.digitalocean.com/community/questions/node-gyp-rebuild-fails-on-install,您可以尝试以下操作:
sudo npm install -g node-gyp@latest
sudo npm explore -g npm -- npm i node-gyp@latest
如果这些不起作用,它表示可能删除应用程序并重新推送它可能会修复它。