错误:部署到heroku时找不到模块'webpack' [英] Error: Cannot find module 'webpack' when deploying to heroku

查看:201
本文介绍了错误:部署到heroku时找不到模块'webpack'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从其他主题来看(没有哪个帮助过我),这似乎是一个反复出现的问题,我试图将我的应用部署到heroku。它可以很好的与 heroku local web ,我已经部署了应用程序和 git heroku push 我运行 heroku打开,没有加载,我得到以下错误:


应用程序错误应用程序中发生错误,您的页面
无法投放。如果您是应用程序所有者,请查看您的日志
了解详情。


我检查了我的日志, p>

 错误:无法找到模块'webpack'

我的包JSON具有以下依赖关系:

 依赖关系:{
babel-runtime:^ 6.20.0,
react:^ 15.4.1,
react-dom:^ 15.4.1,
react-timestamp:^ 3.1.0,
superagent:^ 3.3.2
},
devDependencies:{
babel-core :^ 6.21.0,
babel-eslint:^ 7.1.1,
babel-loader:^ 6.2.10,
babel-plugin -react-transform:^ 2.0.2,
babel-plugin-transform-runtime:^ 6.15.0,
babel-preset-es2015:^ 6.18。 0,
babel-preset-react:^ 6.16.0,
babel-preset-stage-0:^ 6.16.0,
env:^ 3.1.3,
css-loader:^ 0.26.1,
eslint:^ 3.12.2,
eslint-config - airbnb:^ 13.0.0,
eslint-formatter-pretty:^ 1.1.0,
eslint-plugin-compat:^ 0.1.1,
eslint-plugin-import:^ 2.2.0,
eslint-plugin-jsx-a11y:2.2.3,
eslint-plugin-promise: ^ 3.4.0,
eslint-plugin-react:^ 6.8.0,
extract-text-webpack-plugin:^ 1.0.1,
react-transform-hmr:^ 1.0.4,
style-loader:^ 0.13.1,
webpack:^ 1.14.0,
webpack-dev-server:^ 1.16.2
}

脚本:

 scripts:{
start:node server.js,
build:cross-env BABEL_ENV = production ./node_modules/.bin/webpack --config webpack.config.production.js,
lint:eslint --cache --ignore-path .gitignore --format = node_modules / eslint-formatter-pretty。 * .js,
test:npm run lint
},





新的更新依赖性

 依赖关系:{
babel-runtime:^ 6.20.0,
extract-text-webpack-plugin:^ 1.0.1,
react:^ 15.4.1,
react-dom:^ 15.4.1,
react-timestamp:^ 3.1.0,
superagent:^ 3.3.2,
webpack:^ 1.14.0,
webpack-combine-loaders:^ 2.0.3,
webpack-dev-server:^ 1.16.2,

babel-core:^ 6.21.0,
babel-eslint:^ 7.1.1,
babel-loader:^ 6.2.10,
babel-plugin-react-转换:^ 2.0.2,
babel-plugin-transform-runtime:^ 6.15.0,
babel-preset-es2015:^ 6.18.0,
babel-preset-react:^ 6.16.0,
babel-preset-stage-0:^ 6.16.0

},
devDependencies:{
cross-env:^ 3.1.3,
css-loader:^ 0.26.1,
eslint:^ 3.12.2,
eslint-config-airbnb:^ 13.0.0,
eslint-formatter-pretty:^ 1.1.0,
eslint-plugin-compat:^ 0.1.1,
eslint-plugin-import:^ 2.2.0,
eslint-plugin-jsx-a11y: 2.2.3,
eslint-plugin-promise:^ 3.4.0,
eslint-plugin-react:^ 6.8.0,
react -transform-hmr:^ 1.0.4,
style-loader:^ 0.13.1

}

错误

  2017-01-24T13:19: 09.342589 + 00:00 app [web.1]:webpack:bundle现在有效。 
2017-01-24T13:20:01.547772 + 00:00 heroku [web.1]:错误R10(启动超时) - > Web进程无法在启动后的60秒内绑定到$ PORT
2017-01-24T13:20:01.547772 + 00:00 heroku [web.1]:使用SIGKILL停止进程
2017-01-24T13 :20:01.695160 + 00:00 heroku [web.1]:进程已退出,状态为137
2017-01-24T13:20:01.703185 + 00:00 heroku [web.1]:状态从开始更改为崩溃
2017-01-24T13:25:57.948086 + 00:00 heroku [router]:at = error code = H10 desc =App crashedmethod = GET path =/host = whapp.herokuapp.com request_id = 9206d33a-fd68-461d-a4d9-dd620ad9d1c8 fwd =94.119.64.6dyno = connect = service = status = 503 bytes =
2017-01-24T13:25:58.798446 + 00:00 heroku [router]: at = error code = H10 desc =App crashedmethod = GET path =/ favicon.icohost = wheather-app.herokuapp.com request_id = 48131770-43d1-4702-b201-244ec94a8011 fwd =94.119.64.17 dyno = connect = service = status = 503 bytes =
2017-01-24T13:27:07.565562 + 00:00 heroku [router]:at = error code = H10 desc =App crashedmethod = GET path = /host = whapp.herokuapp.com request_id = d38c3a55-6b83-4afa-85dc -944cb4607482 fwd =94.119.64.7dyno = connect = service = status = 503 bytes =
2017-01-24T13:27:08.488193 + 00:00 heroku [router]:at = error code = H10 desc = app crashedmethod = GET path =/ favicon.icohost = wheather-app.herokuapp.com request_id = fe267ccf-e202-46e6-aa47-1dc0fd2b8c78 fwd =94.119.64.4dyno = connect = service = status = 503字节=


解决方案

将webpack依靠将你的 Heroku slug 从devDependencies构建到你的包中的dependencies .json。



您应该可以使用普通的webpack而不是./node_modules/.bin/webpack来调用它。



默认情况下,devDependencies仅安装在开发平台上的node_modules中,而Heroku被定义为生产平台。


Judging from other topics (none which helped me), this seems to be a reoccurring issue, I am trying to deploy my app to heroku. It works fine with heroku local web, I have deployed the app and git heroku push to the master but as soon as I run heroku open, nothing loads and I get the following error:

Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.

I checked my logs and it says:

Error: Cannot find module 'webpack'

My Package JSON has the following dependencies:

  "dependencies": {
    "babel-runtime": "^6.20.0",
    "react": "^15.4.1",
    "react-dom": "^15.4.1",
    "react-timestamp": "^3.1.0",
    "superagent": "^3.3.2"
  },
  "devDependencies": {
    "babel-core": "^6.21.0",
    "babel-eslint": "^7.1.1",
    "babel-loader": "^6.2.10",
    "babel-plugin-react-transform": "^2.0.2",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-preset-es2015": "^6.18.0",
    "babel-preset-react": "^6.16.0",
    "babel-preset-stage-0": "^6.16.0",
    "cross-env": "^3.1.3",
    "css-loader": "^0.26.1",
    "eslint": "^3.12.2",
    "eslint-config-airbnb": "^13.0.0",
    "eslint-formatter-pretty": "^1.1.0",
    "eslint-plugin-compat": "^0.1.1",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "2.2.3",
    "eslint-plugin-promise": "^3.4.0",
    "eslint-plugin-react": "^6.8.0",
    "extract-text-webpack-plugin": "^1.0.1",
    "react-transform-hmr": "^1.0.4",
    "style-loader": "^0.13.1",
    "webpack": "^1.14.0",
    "webpack-dev-server": "^1.16.2"
  }

Scripts:

  "scripts": {
    "start": "node server.js",
    "build": "cross-env BABEL_ENV=production ./node_modules/.bin/webpack --config webpack.config.production.js",
    "lint": "eslint --cache --ignore-path .gitignore --format=node_modules/eslint-formatter-pretty . *.js",
    "test": "npm run lint"
  },

What do I have to do to get it running on heroku? Do you need to install webpack on the server?? How does this work

NEW UPDATE TO DEPENDENCIES

  "dependencies": {
    "babel-runtime": "^6.20.0",
    "extract-text-webpack-plugin": "^1.0.1",
    "react": "^15.4.1",
    "react-dom": "^15.4.1",
    "react-timestamp": "^3.1.0",
    "superagent": "^3.3.2",
    "webpack": "^1.14.0",
    "webpack-combine-loaders": "^2.0.3",
    "webpack-dev-server": "^1.16.2",

      "babel-core": "^6.21.0",
      "babel-eslint": "^7.1.1",
      "babel-loader": "^6.2.10",
      "babel-plugin-react-transform": "^2.0.2",
      "babel-plugin-transform-runtime": "^6.15.0",
      "babel-preset-es2015": "^6.18.0",
      "babel-preset-react": "^6.16.0",
      "babel-preset-stage-0": "^6.16.0"

  },
  "devDependencies": {
    "cross-env": "^3.1.3",
    "css-loader": "^0.26.1",
    "eslint": "^3.12.2",
    "eslint-config-airbnb": "^13.0.0",
    "eslint-formatter-pretty": "^1.1.0",
    "eslint-plugin-compat": "^0.1.1",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "2.2.3",
    "eslint-plugin-promise": "^3.4.0",
    "eslint-plugin-react": "^6.8.0",
    "react-transform-hmr": "^1.0.4",
    "style-loader": "^0.13.1"

  }

ERROR

2017-01-24T13:19:09.342589+00:00 app[web.1]: webpack: bundle is now VALID.
2017-01-24T13:20:01.547772+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-01-24T13:20:01.547772+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-01-24T13:20:01.695160+00:00 heroku[web.1]: Process exited with status 137
2017-01-24T13:20:01.703185+00:00 heroku[web.1]: State changed from starting to crashed
2017-01-24T13:25:57.948086+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=whapp.herokuapp.com request_id=9206d33a-fd68-461d-a4d9-dd620ad9d1c8 fwd="94.119.64.6" dyno= connect= service= status=503 bytes=
2017-01-24T13:25:58.798446+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=wheather-app.herokuapp.com request_id=48131770-43d1-4702-b201-244ec94a8011 fwd="94.119.64.17" dyno= connect= service= status=503 bytes=
2017-01-24T13:27:07.565562+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=whapp.herokuapp.com request_id=d38c3a55-6b83-4afa-85dc-944cb4607482 fwd="94.119.64.7" dyno= connect= service= status=503 bytes=
2017-01-24T13:27:08.488193+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=wheather-app.herokuapp.com request_id=fe267ccf-e202-46e6-aa47-1dc0fd2b8c78 fwd="94.119.64.4" dyno= connect= service= status=503 bytes=

解决方案

Move webpack (and any other tools you rely on for building your Heroku slug from "devDependencies" to "dependencies" in your package.json.

You should also be able to call it with just plain "webpack" instead of ./node_modules/.bin/webpack.

By default, "devDependencies" only get installed in node_modules on Dev platforms, whereas Heroku is defined as a production platform.

这篇关于错误:部署到heroku时找不到模块'webpack'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆