node-pre-gyp 安装错误由于可能与节点冲突

node-pre-gyp install error due to possible conflict with node

我尝试安装失败,运行 amp-paywall-demo 示例可在 AmpProject GitHub 存储库中找到:https://github.com/ampproject/samples/tree/master/amp-paywall-demo 我已经在那里提出了 Issue ticket,但到目前为止没有收到任何回复 (https://github.com/ampproject/samples/issues/211)

我尝试按照安装指南进行操作:我克隆了存储库(这按预期工作),然后是 npm install,不幸的是失败了。

我尝试自己调试错误但无法调试。 我还搜索了该错误,并在 Git 存储库中的问题中搜索了类似的问题,但这也没有帮助。

我用错误的输出创建了 public 要点,以及 debug.log 文件

调试:https://gist.github.com/rafaelmarques7/707f1932f63cd042cdf1e6952c1093ab

错误堆栈如下:

➜  amp-paywall-demo git:(master) ✗ sudo npm i

> grpc@0.14.1 install /home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcl
oud/node_modules/grpc
> node-pre-gyp install --fallback-to-build

node-pre-gyp info it worked if it ends with ok
node-pre-gyp verb cli [ '/usr/bin/node',
node-pre-gyp verb cli   '/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/
gcloud/node_modules/grpc/node_modules/.bin/node-pre-gyp',
node-pre-gyp verb cli   'install',
node-pre-gyp verb cli   '--fallback-to-build' ]
node-pre-gyp info using node-pre-gyp@0.6.28
node-pre-gyp info using node@10.15.1 | linux | x64
node-pre-gyp verb command install []
node-pre-gyp info check checked for "/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/n
ode_modules/gcloud/node_modules/grpc/src/node/extension_binary/grpc_node.node" (not found)
node-pre-gyp http GET https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v0.14.1/no
de-v64-linux-x64.tar.gz
node-pre-gyp http 403 https://storage.googleapis.com/grpc-precompiled-binaries/node/grpc/v0.14.1/no
de-v64-linux-x64.tar.gz
node-pre-gyp ERR! Tried to download: https://storage.googleapis.com/grpc-precompiled-binaries/node/
grpc/v0.14.1/node-v64-linux-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for grpc@0.14.1 and node@10.15.1 (node-v64 ABI) (fal
ling back to source compile with node-gyp) 
node-pre-gyp http 403 status code downloading tarball https://storage.googleapis.com/grpc-precompil
ed-binaries/node/grpc/v0.14.1/node-v64-linux-x64.tar.gz 
node-pre-gyp verb command build [ 'rebuild' ]
node-pre-gyp ERR! Tried to download: https://storage.googleapis.com/grpc-precompiled-binaries/node/
grpc/v0.14.1/node-v64-linux-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for grpc@0.14.1 and node@10.15.1 (node-v64 ABI) (fal
ling back to source compile with node-gyp) 
node-pre-gyp http Connection closed while downloading tarball file 
node-pre-gyp verb command build [ 'rebuild' ]
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/rafael/proj/tuts/amp-publisher-sample
/amp-paywall-demo/node_modules/gcloud/node_modules/grpc/build'
gyp ERR! System Linux 4.15.0-45-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc/src/node/extension_binary/grpc_node.node" "--module_name=grpc_node" "--module_path=/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc/src/node/extension_binary"
gyp ERR! cwd /home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc
gyp ERR! node -v v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc/src/node/extension_binary/grpc_node.node --module_name=grpc_node --module_path=/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc/src/node/extension_binary' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:970:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Linux 4.15.0-45-generic
node-pre-gyp ERR! command "/usr/bin/node" "/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc
node-pre-gyp ERR! node -v v10.15.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.28
node-pre-gyp ERR! not ok 
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc/src/node/extension_binary/grpc_node.node --module_name=grpc_node --module_path=/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc/src/node/extension_binary' (1)
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc/build'
gyp ERR! System Linux 4.15.0-45-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc/src/node/extension_binary/grpc_node.node" "--module_name=grpc_node" "--module_path=/home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc/src/node/extension_binary"
gyp ERR! cwd /home/rafael/proj/tuts/amp-publisher-sample/amp-paywall-demo/node_modules/gcloud/node_modules/grpc
gyp ERR! node -v v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN amp-publisher@0.0.1 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@0.14.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the grpc@0.14.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/rafael/.npm/_logs/2019-02-15T09_29_56_863Z-debug.log

我也想知道为什么安装要尝试安装名为 node-pre-gyp 的东西,它没有在 package.json:

中列出
{
  "name": "amp-publisher",
  "version": "0.0.1",
  "description": "A sample implementation for an AMP Publisher",
  "main": "app.js",
  "engines": {
    "node": "^4.0.0"
  },
  "author": "The AMP HTML Authors",
  "license": "Apache-2.0",
  "scripts": {
    "start": "node app.js",
    "monitor": "nodemon app.js",
    "deploy": "gcloud preview app deploy app.yaml",
    "lint": "jshint --exclude-path=.gitignore .",
    "test": "npm run lint"
  },
  "dependencies": {
    "body-parser": "1.18.3",
    "cookie-parser": "1.4.3",
    "express": "4.16.4",
    "gcloud": "^0.37.0",
    "hogan-express": "0.5.2",
    "hogan.js": "^3.0.2",
    "jsonwebtoken": "^8.0.0",
    "uuid": "3.3.2"
  },
  "devDependencies": {
    "jshint": "2.9.7"
  }
}

非常感谢, 拉斐尔

你的错误原因是 grpc 包的版本 (0.14.1) 与你使用的 NodeJs 版本 (10.15.1) 不兼容:

Pre-built binaries not found for grpc@0.14.1 and node@10.15.1

您可以尝试使用旧版本的 NodeJs,看看是否有帮助。但是,如果您尝试使用更多最新的依赖项可能会更好 - gcloud@^0.37.0 已经有 2 年的历史了,并且已经 deprecated.
gcloud 所需的 grpc@0.14.1 的最新版本是 1.18.0。

I am also wondering why the installation is trying to install something called node-pre-gyp, which is not listed in the package.json

node-pre-gyp 用于从二进制文件安装包的 C++ 模块。在您的情况下,它会自动用于安装 C++ gprc 包,以便您可以在 NodeJs 上下文中使用它。

你可以试试这些命令

nvm install --lts
nvm use --lts
rm -rf node_modules && rm package-lock.json
npm install .