Heroku在部署应用程序时不安装依赖项

时间:2014-08-23 03:43:07

标签: node.js heroku

iv我的应用程序在heroku上运行了一个月,今天我添加了一个登录功能。我在本地计算机上推送了运行良好的更新,但是当我在heroku上启动时,我收到错误说

An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details

这是我在heroku控制台上的错误:

           ^
2014-08-23T03:33:15.894737+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
2014-08-23T03:33:15.694754+00:00 app[web.1]: > application-name@0.0.1 start /app
2014-08-23T03:33:15.694756+00:00 app[web.1]: > node ./bin/www
2014-08-23T03:33:15.892108+00:00 app[web.1]: 
2014-08-23T03:33:15.892717+00:00 app[web.1]:     throw err;
2014-08-23T03:33:15.894741+00:00 app[web.1]:     at require (module.js:380:17)
2014-08-23T03:33:15.894747+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:474:10)
2014-08-23T03:33:15.894731+00:00 app[web.1]: Error: Cannot find module 'mongoose/'
2014-08-23T03:33:15.894734+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
2014-08-23T03:33:15.894739+00:00 app[web.1]:     at Module.require (module.js:364:17)
2014-08-23T03:33:15.894753+00:00 app[web.1]:     at Module.require (module.js:364:17)
2014-08-23T03:33:15.894743+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:7:16)
2014-08-23T03:33:15.894749+00:00 app[web.1]:     at Module.load (module.js:356:32)
2014-08-23T03:33:15.901426+00:00 app[web.1]: 
2014-08-23T03:33:15.894745+00:00 app[web.1]:     at Module._compile (module.js:456:26)
2014-08-23T03:33:15.894751+00:00 app[web.1]:     at Function.Module._load (module.js:312:12)
2014-08-23T03:33:14.758661+00:00 heroku[web.1]: Starting process with command `npm start`
2014-08-23T03:33:16.526792+00:00 heroku[web.1]: Process exited with status 1

这没有任何意义,因为我已经拥有猫鼬并且一直坐在app.js,因为我第一次部署它没有任何问题! urgh。

这只是在我尝试推送新更新时才启动,因为我将我的mac更新为 yosemite

我尝试过我在网上看过的所有内容,但似乎没有任何工作,例如(heroku restart)任何想法?

额外信息: 在部署应用程序时,这就是我在终端中获得的内容:

-----> Defaulting to latest stable node: 0.10.31
-----> Downloading and installing node
-----> Restoring node_modules directory from cache
-----> Pruning cached dependencies not specified in package.json
-----> Exporting config vars to environment
-----> Installing dependencies
-----> Caching node_modules directory for future builds
-----> Cleaning up node-gyp and npm artifacts
-----> No Procfile found; Adding npm start to new Procfile
-----> Building runtime environment
-----> Discovering process types
       Procfile declares types -> web

-----> Compressing... done, 8.6MB
-----> Launching... done, v27
       http://nefs.herokuapp.com/ deployed to Heroku

亲切的问候

2 个答案:

答案 0 :(得分:1)

真的很老,但我今天遇到了这个问题,并认为将答案放在这里可能是个好主意: 在我的例子中,它是package.json文件。它没有将mongoose列为依赖项,因此安装mongoose --save&#39;解决了这个问题。

答案 1 :(得分:1)

我遇到了同样的问题。依赖关系第一次安装。之后我对package.json的更改没有反映在Heroku应用程序中。

这主要是由于两个原因

  1. Heroku正在缓存node_modules
  2. Heroku在生产模式下运行,忽略了devDependencies。
  3. 请参阅以下链接,我已经分享了如何解决这两个问题。

    https://stackoverflow.com/a/45073405/3436826

相关问题