所以我以前的构建工作得很好然后我在终端中看到一个警告,指出我使用的 npm 版本与我的 package.json 中提到的 npm 版本不同,所以我在 package.json 中更新了我的 npm 版本文件,然后 Heroku 构建开始失败。所以我挖掘了一些挖掘并在相关帖子中发现如果我删除了我的 package-lock.json 文件。它应该完成这项工作。所以,我做了同样的事情,它奏效了。但我想知道为什么它不适用于包锁定文件。我再次尝试通过执行 npm install 再次创建包锁定文件,但这次构建也失败了。那么有没有什么办法可以用 package-lock.json 来构建构建日志呢?
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 14.17.0
engines.npm (package.json): 7.8.0
Resolving node version 14.17.0...
Downloading and installing node 14.17.0...
Bootstrapping npm 7.8.0 (replacing 6.14.13)...
npm 7.8.0 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_417a83d9/node_modules/bcrypt
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@7.1.2
npm ERR! gyp info using node@14.17.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.6.9 found at "/usr/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v14.17.0/node-v14.17.0-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v14.17.0/node-v14.17.0-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v14.17.0/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v14.17.0/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/tmp/build_417a83d9/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/tmp/build_417a83d9/node_modules/bcrypt/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/tmp/build_417a83d9/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/app/.cache/node-gyp/14.17.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/app/.cache/node-gyp/14.17.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/tmp/build_417a83d9/.heroku/node/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/app/.cache/node-gyp/14.17.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/tmp/build_417a83d9/node_modules/bcrypt',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onCpExit (/tmp/build_417a83d9/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:376:20)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Linux 4.4.0-1088-aws
npm ERR! gyp ERR! command "/tmp/build_417a83d9/.heroku/node/bin/node" "/tmp/build_417a83d9/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /tmp/build_417a83d9/node_modules/bcrypt
npm ERR! gyp ERR! node -v v14.17.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.ng4R4/_logs/2021-05-20T12_41_05_572Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed ```