当前位置: 首页 > 面试题库 >

Nodejs Bcrypt + Heroku部署失败

龚博涛
2023-03-14
问题内容

当我尝试在heroku中进行部署时遇到问题。有趣的是,这是三天前的工作。另外,在本地计算机上工作正常。

Bcrypt的版本是3.0.0,节点8.12.0

我确实需要部署此服务器。您能告诉我如何解决此错误吗?我尝试了一些找到的解决方案,但没有任何效果。我什至尝试卸载并再次安装Bcrypt,但无法正常工作。

谢谢您的帮助。

这是日志。

-----> Node.js app detected

-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true

-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)

       Resolving node version 8.x...
       Downloading and installing node 8.12.0...
       Using default npm version: 6.4.1

-----> Restoring cache
       - node_modules

-----> Building dependencies
       Installing node modules (package.json + package-lock)

       > bcrypt@3.0.0 install /tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt
       > node-pre-gyp install --fallback-to-build

       make: Entering directory '/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/build'
       make: Entering directory '/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/build'
       CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
       CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
       rm: cannot remove './Release/.deps/Release/obj.target/bcrypt_lib/src/blowfish.o.d.raw': No such file or directory
       bcrypt_lib.target.mk:103: recipe for target 'Release/obj.target/bcrypt_lib/src/blowfish.o' failed
       make: *** [Release/obj.target/bcrypt_lib/src/blowfish.o] Error 1
       make: Leaving directory '/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/build'
       CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
       gyp ERR! build error
       gyp ERR! stack Error: `make` failed with exit code: 2
       gyp ERR! stack     at ChildProcess.onExit (/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
       gyp ERR! stack     at emitTwo (events.js:126:13)
       gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
       gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
       gyp ERR! System Linux 4.4.0-1027-aws
       gyp ERR! command "/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/.heroku/node/bin/node" "/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/lib/binding" "--napi_version=3" "--node_abi_napi=napi"
       gyp ERR! cwd /tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt
       gyp ERR! node -v v8.12.0
       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 '/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/.heroku/node/bin/node /tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/lib/binding --napi_version=3 --node_abi_napi=napi' (1)
       node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
       node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
       node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
       node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:915:16)
       node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
       node-pre-gyp ERR! System Linux 4.4.0-1027-aws
       node-pre-gyp ERR! command "/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/.heroku/node/bin/node" "/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
       node-pre-gyp ERR! cwd /tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt
       node-pre-gyp ERR! node -v v8.12.0
       node-pre-gyp ERR! node-pre-gyp -v v0.10.2
       node-pre-gyp ERR! not ok
       Failed to execute '/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/.heroku/node/bin/node /tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/lib/binding --napi_version=3 --node_abi_napi=napi' (1)
       ../src/bcrypt.cc:316:1: fatal error: opening dependency file ./Release/.deps/Release/obj.target/bcrypt_lib/src/bcrypt.o.d.raw: No such file or directory
       compilation terminated.
       bcrypt_lib.target.mk:103: recipe for target 'Release/obj.target/bcrypt_lib/src/bcrypt.o' failed
       make: *** [Release/obj.target/bcrypt_lib/src/bcrypt.o] Error 1
       make: Leaving directory '/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/build'
       gyp ERR! build error
       gyp ERR! stack Error: `make` failed with exit code: 2
       gyp ERR! stack     at ChildProcess.onExit (/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
       gyp ERR! stack     at emitTwo (events.js:126:13)
       gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
       gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
       gyp ERR! System Linux 4.4.0-1027-aws
       gyp ERR! command "/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/.heroku/node/bin/node" "/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt/lib/binding" "--napi_version=3" "--node_abi_napi=napi"
       gyp ERR! cwd /tmp/build_7bec2ec99162a9fbf0c48b54d7fcf7ea/node_modules/bcrypt
       gyp ERR! node -v v8.12.0
       gyp ERR! node-gyp -v v3.8.0
       gyp ERR! not ok
       npm ERR! code ELIFECYCLE
       npm ERR! errno 1
       npm ERR! bcrypt@3.0.0 install: `node-pre-gyp install --fallback-to-build`
       npm ERR! Exit status 1
       npm ERR!
       npm ERR! Failed at the bcrypt@3.0.0 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!     /tmp/npmcache.FCizS/_logs/2018-09-12T04_21_02_165Z-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

       Some possible problems:

       - Node version not specified in package.json
       https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version

       Love,
       Heroku

 !     Push rejected, failed to compile Node.js app.
 !     Push failed

问题答案:

我也发生了同样的事情。

未在package.json中指定的节点版本

尝试执行heroku的建议,在上定义要使用的节点版本package.json

获取用于开发的版本:

node --version

然后戴上package.json

{ "name": "myapp", 
  "description": "a really cool app",  
  "version": "1.0.0", 
  "engines": { 
      "node": "8.9.4" 
   }
}


 类似资料:
  • 我正在为一个业余项目工作Java REST api,我使用Heroku作为我的部署平台。我设法使用部署了应用程序。 检测不到set buildpack https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/java.tgz 更多信息:https://devcenter.heroku.com/articles/buildpacks#d

  • 推荐先去了解下 在 Heroku 里部署 node.js 应用的文档。 首先,我们需要告诉 Heroku 安装项目的开发依赖包 devDependencies (以便能在 Heroku 环境下运行 npm run build): heroku config:set NPM_CONFIG_PRODUCTION=false 同时,我们想让应用以 生产模式 运行,绑定的主机IP为 0.0.0.0: he

  • 尝试在Heroku云中部署Spring Boot应用程序,但编译java应用程序时出现错误,但在我的本地计算机中运行良好。

  • 问题内容: 我正在尝试将Flask应用程序部署到Heroku,但是在推送代码时出现错误 我不确定该怎么做,我尝试将端口从5000更改为33507,但无济于事。我的Procfile看起来像这样: main.py 是启动服务器的主要Flask文件。 问题答案: 在Heroku托管的Flask应用中,我使用以下代码启动服务器: 在本地开发时,它将使用端口5000,在生产环境中,Heroku将设置环境变量

  • 目标 将 https://github.com/Ricardo-Li/node-practice-2 (这个项目已经被删了。参照 https://github.com/alsotang/node-lessons/tree/master/lesson3 的代码自己操作一下吧。)这个项目部署上 heroku,成为一个线上项目 我部署的在这里 http://serene-falls-9294.herok

  • 目标: 将我的strapi服务器部署到heroku,这样我就可以有一个无头的CMS。 错误: 系统: node.js版本:12.13.0 NPM版本:6.12.0 strapi版本:3.0.0-beta.17.4 数据库:MongoDB atlas Cloud 操作系统:LinuxMint 19.2 Cinnamon 前端:React 16.11.0 我试过: Strapi heroku部署指南