【发布时间】:2022-02-10 14:12:37
【问题描述】:
我已成功部署应用程序,但尝试在 Heroku 上运行该应用程序时,出现以下错误:
2022-01-02T05:26:45.612777+00:00 heroku[web.1]: Starting process with command `npm start`
2022-01-02T05:26:46.989656+00:00 app[web.1]: > tic-tac-toe@1.0.0 start /app
2022-01-02T05:26:46.989657+00:00 app[web.1]: > npm run open
2022-01-02T05:26:47.536042+00:00 app[web.1]: > tic-tac-toe@1.0.0 open /app
2022-01-02T05:26:47.536043+00:00 app[web.1]: > open index.html
2022-01-02T05:26:47.539616+00:00 app[web.1]: sh: 1: open: not found
2022-01-02T05:26:47.543563+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2022-01-02T05:26:47.543721+00:00 app[web.1]: npm ERR! syscall spawn
2022-01-02T05:26:47.543782+00:00 app[web.1]: npm ERR! file sh
2022-01-02T05:26:47.543850+00:00 app[web.1]: npm ERR! errno ENOENT
2022-01-02T05:26:47.546906+00:00 app[web.1]: npm ERR! tic-tac-toe@1.0.0 open: `open index.html`
当我在我的系统上运行它时,节点脚本运行得很好。有人可以提出什么问题吗?
package.json 中的脚本是:
"scripts": { "start": "npm run open", "open": "open index.html" },
【问题讨论】:
-
为什么要在浏览器中打开服务器端的index.html?它们通常在没有 Window 系统的情况下无头运行,因此您不能在那里使用图形应用程序。我认为您误解了这一点,并希望通过 http 将 index.html 提供给客户端
-
Heroku 部署系统需要一个启动脚本来运行应用程序并打开 index.html 文件,我必须使用 nodeJS open 命令。有其他选择吗?
-
编写一个 node.js http 服务器来为 index.html 提供服务。不清楚你想要什么,这听起来像xy problem