将 web3 应用程序部署到 heroku 时找不到 node-gyp-build

问题描述

我正在尝试将 web3 应用程序部署到 heroku,但是在构建 npm 依赖项时,我收到以下错误

remote: sh: 1: node-gyp-build: not found
remote: npm ERR! code ELIFECYCLE                                                                                                  
remote: npm ERR! syscall spawn                                                                                                    
remote: npm ERR! file sh                                                                                                          
remote: npm ERR! errno ENOENT                                                                                                     
remote: npm ERR! bufferutil@4.0.3 install: `node-gyp-build`                                                                       
remote: npm ERR! spawn ENOENT                                                                                                     
remote: npm ERR!                                                                                                                  
remote: npm ERR! Failed at the bufferutil@4.0.3 install script. 

我相信这是因为我添加了 web3@1.3.6 依赖项。如果我在 package.json 文件中的 npm 依赖项中忽略了这一点,部署将成功运行。

如果我通过 ssh 进入控制台,我可以运行 npm install -g web3@1.3.6 并且这也是成功的。我还尝试在 package.json 文件添加 node-gyp、node-gyp-build 和 bufferutil 作为显式依赖项。我正在使用

node 14.17.0 npm 6.14.13 python 3.9.5

以下是我的完整 package.json 文件

{
  "engines": {
    "node": "14.17.0","npm": "6.14.13"
  },"repository": {},"description": " ","license": "MIT","scripts": {
    "deploy": "webpack --mode production","watch": "webpack --mode development --watch"
  },"dependencies": {
    "postcss": "8.1.0","@popperjs/core": "^2.9.2","bootstrap": "^5.0.1","jquery": "^3.6.0","phoenix": "file:../deps/phoenix","phoenix_html": "file:../deps/phoenix_html","phoenix_live_view": "file:../deps/phoenix_live_view","topbar": "^0.1.4","@babel/core": "^7.0.0","babel-polyfill": "^6.26.0","@babel/preset-env": "^7.0.0","babel-loader": "^8.0.0","css-loader": "^5.2.6","sass-loader": "^10.0.0","node-sass": "^6.0.0","cropperjs": "1.5.12","eth-sig-util": "^1.4.2","jquery-cropper": "1.0.1","copy-webpack-plugin": "^5.1.1","hard-source-webpack-plugin": "^0.13.1","mini-css-extract-plugin": "^0.9.0","optimize-css-assets-webpack-plugin": "^5.0.1","terser-webpack-plugin": "^2.3.2","webpack": "^4.41.5","webpack-cli": "^3.3.2","web3": "1.3.6"
  },"devDependencies": {},}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)