Heroku无法部署ENOENT

时间:2018-05-02 14:58:46

标签: heroku npm

我一直在尝试在heroku上部署我的应用程序,但我一直遇到同样的错误:

-----> 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.11.1...
       Using default npm version: 5.6.0
-----> Restoring cache
       Skipping cache restore (not-found)
-----> Building dependencies
       Prebuild detected (node_modules already exists)
       Rebuilding any native modules
       npm ERR! path /tmp/build_b970b614b48136e1f3dc8a90ee8f11d9/node_modules/har-validator/bin/har-validator
       npm ERR! code ENOENT
       npm ERR! errno -2
       npm ERR! syscall chmod
       npm ERR! enoent ENOENT: no such file or directory, chmod '/tmp/build_b970b614b48136e1f3dc8a90ee8f11d9/node_modules/har-validator/bin/har-validator'
       npm ERR! enoent This is related to npm not being able to find a file.
       npm ERR! enoent

       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.wtPoJ/_logs/2018-05-02T14_48_40_930Z-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_modules checked into source control
       https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits

       - 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

应用程序在localhost中正常运行如果我运行npm i然后npm start,我已经尝试完全重建我的package.json,我试图完全删除heroku应用程序并重新创建一个,似乎没有任何帮助。

我的package.json看起来像这样,最标准的可能:

{
  "name": "LAD",
  "version": "1.0.0",
  "description": "xxxxx",
  "repository": "git://github.com/xxx/xxx-LAD",
  "author": "xxxx",
  "license": "xxxxx",
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "^1.18.2",
    "bootstrap": "^3.3.7",
    "compile-sass": "0.0.3",
    "connect-ensure-login": "^0.1.1",
    "connect-flash": "^0.1.1",
    "cookie-parser": "^1.4.3",
    "ejs": "^2.5.9",
    "express": "^4.16.3",
    "express-session": "^1.15.6",
    "morgan": "^1.9.0",
    "passport": "^0.4.0",
    "passport-auth0": "^0.6.1",
    "path": "^0.12.7",
    "serve-favicon": "^2.5.0"
  }
}

1 个答案:

答案 0 :(得分:1)

您是否尝试将node_modules添加到.gitignore文件并检入gitignore文件?

我假设Heroku正在抱怨,因为它正在尝试安装node_modules,但它已在同一位置看到名为node_modules的文件夹。