繁体   English   中英

Heroku Node.js 构建失败:npm 安装期间 node-gyp 抛出错误

[英]Heroku Node.js build failing: node-gyp throws error during npm install

今天早上,当我尝试推送到我的 Heroku 存储库时,我收到了以下失败消息。

我使用的 Node.js 版本与我上次部署时使用的版本相同,但我找不到任何文档来解释失败的含义。

这似乎是 node-gyp 的某种编译问题,但我不知道如何解决它。

这是尝试部署的控制台 output:

Enumerating objects: 43, done.
Counting objects: 100% (43/43), done.
Delta compression using up to 12 threads
Compressing objects: 100% (24/24), done.
Writing objects: 100% (26/26), 16.71 KiB | 2.09 MiB/s, done.
Total 26 (delta 18), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_PRODUCTION=false
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  14.16.0
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 14.16.0...
remote:        Downloading and installing node 14.16.0...
remote:        Using default npm version: 6.14.11
remote:
remote: -----> Restoring cache
remote:        - node_modules
remote:
remote: -----> Installing dependencies
remote:        Installing node modules
remote:
remote:        > sq-native@1.0.10 install /tmp/build_d06f6627/node_modules/sq-native
remote:        > node ./install.js
remote:
remote:
remote:        > event-loop-stats@1.2.0 install /tmp/build_d06f6627/node_modules/event-loop-stats
remote:        > node-gyp rebuild
remote:
remote:        make: Entering directory '/tmp/build_d06f6627/node_modules/event-loop-stats/build'
remote:          CXX(target) Release/obj.target/eventLoopStats/src/eventLoopStats.o
remote:        In file included from ../../nan/nan.h:56,
remote:                         from ../src/eventLoopStats.cc:1:
remote:        /app/.cache/node-gyp/14.16.0/include/node/node.h:758:43: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
remote:          758 |       (node::addon_register_func) (regfunc),                          \
remote:              |                                           ^
remote:        /app/.cache/node-gyp/14.16.0/include/node/node.h:792:3: note: in expansion of macro ‘NODE_MODULE_X’
remote:          792 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
remote:              |   ^~~~~~~~~~~~~
remote:        ../src/eventLoopStats.cc:95:1: note: in expansion of macro ‘NODE_MODULE’
remote:           95 | NODE_MODULE(eventLoopStats, init)
remote:              | ^~~~~~~~~~~
remote:          SOLINK_MODULE(target) Release/obj.target/eventLoopStats.node
remote:          COPY Release/eventLoopStats.node
remote:        make: Leaving directory '/tmp/build_d06f6627/node_modules/event-loop-stats/build'
remote:
remote:        > ejs@2.7.4 postinstall /tmp/build_d06f6627/node_modules/ejs-mate/node_modules/ejs
remote:        > node ./postinstall.js
remote:
remote:
remote:        > bcrypt@5.0.1 install /tmp/build_d06f6627/node_modules/bcrypt
remote:        > node-pre-gyp install --fallback-to-build
remote:
remote:        [bcrypt] Success: "/tmp/build_d06f6627/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" is installed via remot
remote:
remote:        > @sp/omega@0.9.4 postinstall /tmp/build_d06f6627/node_modules/@sp/omega
remote:        > npm run build-files
remote:
remote:
remote:        > @sp/omega@0.9.4 build-files /tmp/build_d06f6627/node_modules/@sp/omega
remote:        > omega build
remote:
remote:        sh: 1: omega: Permission denied
remote:        npm ERR! code ELIFECYCLE
remote:        npm ERR! errno 126
remote:        npm ERR! @sp/omega@0.9.4 build-files: `omega build`
remote:        npm ERR! Exit status 126
remote:        npm ERR!
remote:        npm ERR! Failed at the @sp/omega@0.9.4 build-files script.
remote:        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote:        npm ERR! A complete log of this run can be found in:
remote:        npm ERR!     /tmp/npmcache.4dZx9/_logs/2021-04-06T16_09_47_101Z-debug.log
remote:        npm ERR! code ELIFECYCLE
remote:        npm ERR! errno 126
remote:        npm ERR! @sp/omega@0.9.4 postinstall: `npm run build-files`
remote:        npm ERR! Exit status 126
remote:        npm ERR!
remote:        npm ERR! Failed at the @sp/omega@0.9.4 postinstall script.
remote:        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote:        npm ERR! A complete log of this run can be found in:
remote:        npm ERR!     /tmp/npmcache.4dZx9/_logs/2021-04-06T16_09_47_164Z-debug.log
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        If you're stuck, please submit a ticket so we can help:
remote:        https://help.heroku.com/
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to beta-???????????-net.
remote:
To https://git.heroku.com/beta-???????????-net.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/beta-???????????-net.git'

当 Heroku 尝试npm install event-loop-stats时,会发生此错误。 我们知道是因为错误消息中的这一行。

make: Entering directory '/tmp/build_d06f6627/node_modules/event-loop-stats/build'

该模块使用gyp ,因为安装它需要编译一些 C++ - 使其工作的语言内容。 底部的 npm 页面上有关于兼容性的通知。 按照该通知上的链接显示它适用于节点 v6、v10 和 v12。 但是你告诉 Heroku 使用 v14。

通过将其放入package.json 告诉 heroku 使用 v12

 "engines": {
    "node": "12.x"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM