簡體   English   中英

為什么我的網絡應用程序可以在localhost(npm run dev)上正常運行,但是在部署到heroku時看起來像垃圾?

[英]Why does my web-app work fine on localhost (npm run dev) but look like trash when deployed to heroku?

順便說一句,不是19個Javascript功能的重復項可以在localhost上運行,但在部署到Heroku時不能運行

我要睡覺了,所以我可以離開隧道的本地主機

在此處輸入圖片說明

現在,這就是我在計算機上運行npm run dev時看到的內容。 順便說一句,我覺得這應該是某種簡單的package.json修復,所以這是我的package.json:

{
"name": "hps_prework",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
  "dev": "node app.js",
  "start": "node app.js",
  "build": "next build",
  "test": "react-scripts test --env=jsdom",
  "eject": "react-scripts eject"
},
"engines": {
  "node": "11.6.0"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
  "@material-ui/core": "^3.9.2",
  "@material-ui/icons": "^3.0.2",
  "babel-loader": "^8.0.5",
  "jquery": "^3.3.1",
  "js-cookie": "^2.2.0",
  "koa": "^2.7.0",
  "koa-session": "^5.10.1",
  "next": "^8.0.3",
  "python-shell": "^1.0.7",
  "react": "^16.8.4",
  "react-dom": "^16.8.4",
  "react-scripts": "^2.1.8",
  "webpack": "^4.28.3"
},
"browserslist": [
  ">0.2%",
  "not dead",
  "not ie <= 11",
  "not op_mini all"
]

}

但是這是我的應用程序部署到heroku的樣子:

在此處輸入圖片說明

這是控制台輸出:

在此處輸入圖片說明

這使我相信由於某些原因未加載某些資源。

我想念什么? 回購

最后,這是heroku原木--tail ...

2019-03-21T05:40:54.000000+00:00 app[api]: Build succeeded 2019-03- 
21T05:41:00.603480+00:00 heroku[web.1]: Starting process with command `npm 
start` 2019-03-21T05:41:03.185110+00:00 app[web.1]: 2019-03-            
21T05:41:03.185129+00:00 app[web.1]: > hps_prework@1.0.0 start /app 2019-03- 
21T05:41:03.185131+00:00 app[web.1]: > node app.js 2019-03- 
21T05:41:03.185132+00:00 app[web.1]: 2019-03-21T05:41:03.463015+00:00 
app[web.1]: > Ready on http://localhost:25866 2019-03- 
21T05:41:04.432538+00:00 heroku[web.1]: State changed from starting to up 
2019-03-21T05:41:06.070888+00:00 heroku[router]: at=info method=GET path="/" 
host=summaraize.herokuapp.com request_id=96091bf7-f9c1-45f1-b3b9- 
5b74ce58826f fwd="104.38.101.109" dyno=web.1 connect=0ms service=517ms 
status=200 bytes=3943 protocol=https

Nextjs 文檔自定義服務器package.json的說明:

"scripts": {
  "dev": "node server.js",
  "build": "next build",
  "start": "NODE_ENV=production node server.js"
}

使用自定義服務器(在本例中為Express )的示例應用程序mars / heroku-nextjs-custom-server-express的package.json:

"scripts": {
  "dev": "node server.js -p $PORT",
  "build": "next build",
  "heroku-postbuild": "next build",
  "start": "node server.js -p $PORT"
},

您的package.json:

如果需要,您應該添加heroku-postbuild腳本並在start腳本中設置NODE_ENV和/或PORT

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM