【问题标题】:Error Building on Heroku - Isomorphic App在 Heroku 上构建错误 - 同构应用程序
【发布时间】:2017-03-16 03:33:11
【问题描述】:

尝试在 Heroku 上部署我的应用时,我收到以下错误:

Cannot GET / 
NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier).


Server is being run outside of live development mode, meaning it will only serve the compiled application bundle in ~/dist. Generally you do not need an application server for this and can instead use a web server such as nginx to serve your static files. See the "deployment" section in the README for more information on deployment strategies.

我知道我应该“实时”运行它,而不是从本地主机,所以我通过 CLI 设置了以下设置:

heroku config:set NODE_ENV=production
heroku config:set NODE_PATH=./src
heroku config:set NPM_CONFIG_PRODUCTION=false

我还应该检查什么。该应用程序是该锅炉的克隆:https://github.com/davezuko/react-redux-starter-kit

我的 Heroku 链接是:https://hidden-temple-43853.herokuapp.com/

【问题讨论】:

    标签: javascript heroku isomorphic-javascript


    【解决方案1】:

    假设您不使用 Procfile 来告诉 Heroku 如何启动您的应用程序,则改为使用 package.json will be usednpm start 脚本。

    在部署到 Heroku 之前,您是否正在运行 npm run deployNODE_ENV=production

    Have a look at this issue 建议在部署到 Heroku 时进行修复(复制如下)。

    // ...
    // ------------------------------------
    // Apply Webpack HMR Middleware
    // ------------------------------------
    if (config.env === 'development') {
      const webpackDevMiddleware = require('./middleware/webpack-dev').default
      const webpackHMRMiddleware = require('./middleware/webpack-hmr').default
      const compiler = webpack(webpackConfig)
    
      // Enable webpack-dev and webpack-hot middleware
      const { publicPath } = webpackConfig.output
    
      app.use(webpackDevMiddleware(compiler, publicPath))
      app.use(webpackHMRMiddleware(compiler))
    
    // ...
    

    【讨论】:

      猜你喜欢
      • 2020-03-06
      • 1970-01-01
      • 1970-01-01
      • 2021-08-28
      • 1970-01-01
      • 2022-10-14
      • 1970-01-01
      • 1970-01-01
      • 2017-05-12
      相关资源
      最近更新 更多