Heroku 构建失败(gyp 重建命令失败)

Heroku Build Failing (gyp rebuild command fails)

我在尝试部署到 heroku 时遇到了这个问题:

...
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_BUILD_FLAGS=--no-warnings
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  16.13
       engines.npm (package.json):   8.1
       
       Resolving node version 16.13...
       Downloading and installing node 16.13.2...
       Bootstrapping npm 8.1 (replacing 8.1.2)...
       npm 8.1 installed
       
-----> Restoring cache
       Cached directories were not restored due to a change in version of node, npm, yarn or stack
       Module installation may take longer for this build
       
-----> Installing dependencies
       Installing node modules
       npm ERR! code 1
       npm ERR! path /tmp/build_f02b6ec2/node_modules/java
       npm ERR! command failed
       npm ERR! command sh -c node-gyp rebuild
       npm ERR! gyp info it worked if it ends with ok
       npm ERR! gyp info using node-gyp@8.4.0
       npm ERR! gyp info using node@16.13.2 | linux | x64
       npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
       npm ERR! gyp http GET https://nodejs.org/download/release/v16.13.2/node-v16.13.2-headers.tar.gz
       npm ERR! gyp http 200 https://nodejs.org/download/release/v16.13.2/node-v16.13.2-headers.tar.gz
       npm ERR! gyp http GET https://nodejs.org/download/release/v16.13.2/SHASUMS256.txt
       npm ERR! gyp http 200 https://nodejs.org/download/release/v16.13.2/SHASUMS256.txt
       npm ERR! gyp info spawn /usr/bin/python3
       npm ERR! gyp info spawn args [
       npm ERR! gyp info spawn args   
...

我尝试通过多种方式解决问题,例如将 --no-warnings 添加到 Node Build Flags(您可以尝试 here) 我还尝试了 Heroku 页面中的所有建议来调试构建。 None 有帮助。

你(我)的问题在package.json。您安装了 jdbc,(我知道这一点是因为此处出现错误:npm ERR! path /tmp/build_f02b6ec2/node_modules/java)这似乎是导致问题的原因。尝试将其删除,这将解决您的问题。