简体   繁体   English

Heroku 错误:找不到模块 webpack

[英]Heroku error: Cannot find module webpack

heroku local web works fine but heroku open is throwing Application error. heroku local web工作正常,但heroku open抛出应用程序错误。

I checked the log file.我检查了日志文件。 It says : Cannot find module webpack.它说:找不到模块 webpack。 Complete log file.完整的日志文件。

Niteshs-MacBook-Pro:nyps nitesh$  heroku logs --tail
2016-06-16T03:40:53.132495+00:00 heroku[api]: Enable Logplex by nitesh@campusdiaries.com
2016-06-16T03:40:53.132551+00:00 heroku[api]: Release v2 created by nitesh@campusdiaries.com
2016-06-16T03:45:07.332337+00:00 heroku[api]: Deploy 690eea8 by nitesh@campusdiaries.com
2016-06-16T03:45:07.332405+00:00 heroku[api]: Release v3 created by nitesh@campusdiaries.com
2016-06-16T03:45:07.331714+00:00 heroku[api]: Scale to web=1 by nitesh@campusdiaries.com
2016-06-16T03:45:07.704674+00:00 heroku[slug-compiler]: Slug compilation finished
2016-06-16T03:45:07.704663+00:00 heroku[slug-compiler]: Slug compilation started
2016-06-16T03:45:14.763803+00:00 heroku[web.1]: Starting process with command `node server.js`
2016-06-16T03:45:17.000120+00:00 app[web.1]: module.js:341
2016-06-16T03:45:17.000129+00:00 app[web.1]:     throw err;
2016-06-16T03:45:17.000135+00:00 app[web.1]: 
2016-06-16T03:45:17.000135+00:00 app[web.1]:     ^
2016-06-16T03:45:17.000140+00:00 app[web.1]: Error: Cannot find module 'webpack'
2016-06-16T03:45:17.000141+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:339:15)
2016-06-16T03:45:17.000141+00:00 app[web.1]:     at Function.Module._load (module.js:290:25)
2016-06-16T03:45:17.000142+00:00 app[web.1]:     at Module.require (module.js:367:17)
2016-06-16T03:45:17.000142+00:00 app[web.1]:     at require (internal/module.js:20:19)
2016-06-16T03:45:17.000143+00:00 app[web.1]:     at Object.<anonymous> (/app/server.js:1:77)
2016-06-16T03:45:17.000144+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:422:10)
2016-06-16T03:45:17.000144+00:00 app[web.1]:     at Module._compile (module.js:413:34)
2016-06-16T03:45:17.000145+00:00 app[web.1]:     at Function.Module._load (module.js:314:12)
2016-06-16T03:45:17.000146+00:00 app[web.1]:     at Function.Module.runMain (module.js:447:10)
2016-06-16T03:45:17.000145+00:00 app[web.1]:     at Module.load (module.js:357:32)
2016-06-16T03:45:18.010833+00:00 heroku[web.1]: Process exited with status 1
2016-06-16T03:45:18.019746+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-16T03:45:18.020059+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-16T03:45:20.364946+00:00 heroku[web.1]: Starting process with command `node server.js`
2016-06-16T03:45:22.317904+00:00 app[web.1]: Error: Cannot find module 'webpack'
2016-06-16T03:45:22.317905+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:339:15)
2016-06-16T03:45:22.317899+00:00 app[web.1]: 
2016-06-16T03:45:22.317877+00:00 app[web.1]: module.js:341
2016-06-16T03:45:22.317905+00:00 app[web.1]:     at Function.Module._load (module.js:290:25)
2016-06-16T03:45:22.317892+00:00 app[web.1]:     throw err;
2016-06-16T03:45:22.317909+00:00 app[web.1]:     at Module.load (module.js:357:32)
2016-06-16T03:45:22.317906+00:00 app[web.1]:     at Module.require (module.js:367:17)
2016-06-16T03:45:22.317910+00:00 app[web.1]:     at Function.Module._load (module.js:314:12)
2016-06-16T03:45:22.317907+00:00 app[web.1]:     at require (internal/module.js:20:19)
2016-06-16T03:45:22.317908+00:00 app[web.1]:     at Module._compile (module.js:413:34)
2016-06-16T03:45:22.317907+00:00 app[web.1]:     at Object.<anonymous> (/app/server.js:1:77)
2016-06-16T03:45:22.317908+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:422:10)
2016-06-16T03:45:22.317898+00:00 app[web.1]:     ^
2016-06-16T03:45:22.317910+00:00 app[web.1]:     at Function.Module.runMain (module.js:447:10)
2016-06-16T03:45:23.310093+00:00 heroku[web.1]: Process exited with status 1
2016-06-16T03:45:23.327129+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-16T03:45:30.105406+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nyps.herokuapp.com request_id=096eccfb-7363-4137-88ef-c15389e7a664 fwd="106.51.20.194" dyno= connect= service= status=503 bytes=
2016-06-16T03:45:32.009229+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nyps.herokuapp.com request_id=50951c24-4f9a-4347-963c-70c48560ab90 fwd="106.51.20.194" dyno= connect= service= status=503 bytes=
2016-06-16T03:55:36.073640+00:00 heroku[slug-compiler]: Slug compilation finished
2016-06-16T03:55:36.073633+00:00 heroku[slug-compiler]: Slug compilation started
2016-06-16T03:55:35.881416+00:00 heroku[api]: Deploy 85518b7 by nitesh@campusdiaries.com
2016-06-16T03:55:35.881515+00:00 heroku[api]: Release v4 created by nitesh@campusdiaries.com
2016-06-16T03:55:36.170187+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-16T03:55:51.915142+00:00 heroku[web.1]: Starting process with command `node server.js`
2016-06-16T03:55:57.123301+00:00 app[web.1]: ==> 🌎  Listening on port 3000. Open up http://localhost:3000/ in your browser.
2016-06-16T03:55:56.884371+00:00 app[web.1]: process  production
2016-06-16T03:56:46.013013+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2016-06-16T03:56:46.012815+00:00 heroku[web.1]: Process running mem=556M(108.8%)
2016-06-16T03:56:51.994793+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-06-16T03:56:51.994793+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-06-16T03:56:53.386252+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-16T03:56:53.364620+00:00 heroku[web.1]: Process exited with status 137
2016-06-16T03:56:53.383770+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-16T03:57:01.236167+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=nyps.herokuapp.com request_id=3058277f-f351-4ff9-8cb7-e8500217bf1b fwd="106.51.20.194" dyno= connect= service= status=503 bytes=
2016-06-16T03:57:01.627497+00:00 heroku[web.1]: Starting process with command `node server.js`
2016-06-16T03:57:03.490555+00:00 app[web.1]: ==> 🌎  Listening on port 3000. Open up http://localhost:3000/ in your browser.
2016-06-16T03:57:03.405989+00:00 app[web.1]: process  production
2016-06-16T03:57:23.431249+00:00 app[web.1]: webpack built 114bd08e06394dc17ec8 in 19974ms
2016-06-16T03:58:01.964579+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=nyps.herokuapp.com request_id=ba97ba30-cc4b-493f-8907-4341a650b361 fwd="106.51.20.194" dyno= connect= service= status=503 bytes=
2016-06-16T03:58:02.073841+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-06-16T03:58:02.073797+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-06-16T03:58:02.741937+00:00 heroku[web.1]: Process exited with status 137
2016-06-16T03:58:02.770625+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-16T03:58:04.232803+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nyps.herokuapp.com request_id=db9f5b88-805d-4917-9eb4-2d4827572afc fwd="106.51.20.194" dyno= connect= service= status=503 bytes=
2016-06-16T03:58:06.684479+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nyps.herokuapp.com request_id=6b3b9797-f3d9-48e5-aebd-c157a2603596 fwd="106.51.20.194" dyno= connect= service= status=503 bytes=
2016-06-16T03:58:42.837687+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nyps.herokuapp.com request_id=6a3ca1a5-ed23-416a-b3cf-3e755ee9e88e fwd="106.51.20.194" dyno= connect= service= status=503 bytes=
2016-06-16T03:58:46.216435+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nyps.herokuapp.com request_id=52e5d646-ef1d-418e-8196-ddc79d68001b fwd="106.51.20.194" dyno= connect= service= status=503 bytes=
2016-06-16T04:04:10.169663+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nyps.herokuapp.com request_id=b27e2500-1b84-4d8c-90d1-412a95ca3b13 fwd="106.51.20.194" dyno= connect= service= status=503 bytes=
2016-06-16T04:04:11.771412+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nyps.herokuapp.com request_id=e7e7c74e-656c-4b85-abde-48cc54e3367c fwd="106.51.20.194" dyno= connect= service= status=503 bytes=

I'm calling var webpack = require('webpack') in the first line of my server.js which is called using node server.js我在server.js的第一行调用var webpack = require('webpack')使用node server.js

I deleted node_module;我删除了 node_module; rm -rf node_module Did npm install . rm -rf node_module是否npm installnpm install Still facing the same issue.仍然面临同样的问题。

This is more of a trouble shoot answer, but this issue generally arises with one of two issues:这更像是一个解决问题的答案,但这个问题通常是由以下两个问题之一引起的:

  1. webpack is globally installed (at some point you did npm install webpack -g ) webpack 是全局安装的(在某些时候你做了npm install webpack -g
  2. webpack is installed as a devDependency. webpack 作为 devDependency 安装。

If you are running a server that require's in webpack , you're going to install it as a dependency .如果你在webpack中运行一个需要的服务器,你将把它安装为一个dependency

If you're not doing any serverside middleware, then setting webpack as a devDependency is generally what you want.如果您没有做任何服务器端中间件,那么将webpack设置为 devDependency 通常就是您想要的。

我使用create-react-app的应用程序遇到了同样的问题,我做了什么来解决这个问题,我是在 Heroku 中Buildpacks我的应用程序页面的Settings选项卡,然后在Buildpacks部分添加了: https://buildpack-registry.s3.amazonaws.com/buildpacks/mars/create-react-app.tgz作为https://buildpack-registry.s3.amazonaws.com/buildpacks/mars/create-react-app.tgz

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM