首页 > 解决方案 > 如何解决:部署的 nodejs 应用在 Heroku 上显示为空白

问题描述

本地主机上的工作应用程序。我在部署之前使用了 webpack 和 babel,但是当我点击 heroku URL 时它显示为空白,index.html 什么也没显示。这是构建日志和日志 --tail

-----> Node.js app detected

-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false

-----> Installing binaries
       engines.node (package.json):  >=6
       engines.npm (package.json):   unspecified (use default)

       Resolving node version >=6...
       Downloading and installing node 13.3.0...
       Using default npm version: 6.13.1

-----> Restoring cache
       - node_modules

-----> Installing dependencies
       Installing node modules (package.json + package-lock)
       audited 22264 packages in 14.297s

       17 packages are looking for funding
         run `npm fund` for details

       found 6 vulnerabilities (2 low, 3 moderate, 1 high)
         run `npm audit fix` to fix them, or `npm audit` for details

-----> Build

-----> Caching build
       - node_modules

-----> Pruning devDependencies
       removed 2 packages and audited 22250 packages in 12.798s

       15 packages are looking for funding
         run `npm fund` for details

       found 6 vulnerabilities (2 low, 3 moderate, 1 high)
         run `npm audit fix` to fix them, or `npm audit` for details

-----> Build succeeded!
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
       Done: 78M
-----> Launching...
       Released v8
       https://xxxxxx.herokuapp.com/ deployed to Heroku

日志 --tail 这里: heroku 日志 --tail

标签: node.jsreactjsmongodbexpressheroku

解决方案


我发现在我运行生产脚本后,我构建的静态文件夹没有被推送到 heroku git 上。从 gitignore 中取出文件夹,现在一切正常。干杯。


推荐阅读