首页 > 解决方案 > Heroku 构建失败:heroku-prebuild

问题描述

我最近对我正在尝试部署的项目进行了更新。它之前构建成功,但现在遇到以下错误消息。我不确定错误是什么,因为我已经尝试删除 package-lock.json,清除 npm 缓存并重新安装 npm。提前致谢!

-----> 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):  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

-----> Building dependencies
       Running heroku-prebuild

       > kickstart@1.0.0 heroku-prebuild /tmp/build_ddb0ffb55870b12204585dc338aab661
       > next build

sh: 1: next: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! kickstart@1.0.0 heroku-prebuild: `next build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the kickstart@1.0.0 heroku-prebuild script.

包.json

{
  "name": "kickstart",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "heroku-prebuild": "next build",
    "test": "mocha",
    "dev": "node server.js",
    "start": "next build"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "fs-extra": "^5.0.0",
    "ganache-cli": "^6.1.0",
    "mocha": "^4.1.0",
    "next": "^4.2.3",
    "next-routes": "^1.3.0",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "semantic-ui-css": "^2.3.0",
    "semantic-ui-react": "^0.77.2",
    "solc": "^0.4.21",
    "truffle-hdwallet-provider": "0.0.3",
    "web3": "1.0.0-beta.26"
  },
  "devDependencies": {
    "eslint-config-airbnb": "^16.1.0",
    "eslint-plugin-import": "^2.9.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-react": "^7.7.0"
  }
}

标签: heroku

解决方案


不是 100% 确定,但问题出heroku-prebuild在你打电话的地方next build。此时,尚未安装任何依赖项。你应该next build在不同的阶段运行。您已经将其作为start脚本。


推荐阅读