我以某种方式使我的网站可以在本地运行。但每当我尝试将其上传到 netlify 或 heroku 时,我总是收到错误,或者只是拒绝加载。这是一个 React 应用程序,使用 axios 进行 API 调用以获取加密货币价格。此外,在同一网站的公共文件夹中(其中反应应用程序的index.html是)我有一个webscraping vanilla JS应用程序,它从yahoo.finance提取股票价格并将其存储到CSV(excel文件)中。然后我有一个异步函数可以将 Excel 文件中的数据显示为 HTML。
为了使应用程序显示数据,我必须将 package.json 中的启动脚本更改为
"start": "react-scripts start",
"server": "node public/index.js",
"build": "concurrently \"npm run server\" \"npm run start\"",
我之所以同时使用,是因为我需要启动react服务器“npm start”并同时启动node.js服务器“node index.js”,这样一来就可以显示数据,也可以拉取数据。
如果我执行“npm run build”-它可以完美地工作..如果我将网站上传到netlify或heroku-这是错误的错误..有人知道如何解决这个问题吗?我已经和它斗争了一段时间了:(
更新
Heroku - 它启动了 node.js 服务器,但没有部署网站(我可以看到它在我的终端中更新股票价格,但当我检查 URL 时出错)..它也会抛出此错误
-----> Timed out running buildpack Node.js
Terminated
/tmp/codon/tmp/buildpacks/2cd3309e34d34b154aac9f665b0eb2d2e86d8b8e/lib/monitor.sh: line 1: kill: (3899) - No such process
node:events:504
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at afterWriteDispatched (node:internal/stream_base_commons:160:15)
at writeGeneric (node:internal/stream_base_commons:151:3)
at Socket._writeGeneric (node:net:795:11)
at Socket._write (node:net:807:8)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at Socket.Writable.write (node:internal/streams/writable:334:10)
at OutputWriter.write (/tmp/build_6f046d26/node_modules/concurrently/dist/src/output-writer.js:60:31)
at SafeSubscriber._next (/tmp/build_6f046d26/node_modules/concurrently/dist/src/concurrently.js:71:77)
at SafeSubscriber.__tryOrUnsub (/tmp/build_6f046d26/node_modules/rxjs/internal/Subscriber.js:205:16)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}
! Push failed
对于 Netlify:
这是我的 GITHUB - 也许有人可以自己查看..
我有一个类似的问题 - 我创建了一个仅使用 HTML5 和 CSS3 的网站,没有 Java - 当我上传它时 - css 不起作用 - 但当我在本地打开该网站时它可以工作