[英]/app/.jdk/bin/java: cannot execute binary file using node-pty on Heroku
I am trying to create a node-pty process.我正在尝试创建一个 node-pty 进程。 When developing locally, this works fine and there is no problem.在本地开发时,这工作正常,没有问题。 However, when this runs on Heroku, it gives the error: /app/.jdk/bin/java: cannot execute binary file
但是,当它在 Heroku 上运行时,会出现错误: /app/.jdk/bin/java: cannot execute binary file
I tried running it with just ["java"]
, and that gives the same error.我尝试只用["java"]
运行它,这给出了同样的错误。 So, its unable to start the java binary.因此,它无法启动 java 二进制文件。
However, when I manually type the command, it works just fine.但是,当我手动键入命令时,它工作得很好。
const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';
const ptyProcess = pty.spawn(shell, ["java", "-jar", "Klox.jar"], {
name: 'xterm-color',
cols: 80,
rows: 30,
cwd: process.env.HOME,
env: process.env
});
Any idea how I can solve this?知道如何解决这个问题吗?
Solved the problem,解决了问题,
Instead of spawning the shell with powershell or bash, spawn the shell directly with the executable that you're trying to run. Instead of spawning the shell with powershell or bash, spawn the shell directly with the executable that you're trying to run. So, java
in my case.所以,就我而言, java
。
Effectively, what I did:实际上,我做了什么:
const ptyProcess = pty.spawn("java", ["-jar", "Klox.jar"], {
name: 'xterm-color',
cols: 80,
rows: 30,
cwd: process.env.HOME,
env: process.env
});
So, "java" instead of old shell variable.因此,“java”而不是旧的 shell 变量。
One another thing to keep in mind, on windows add .exe
extension to the end, otherwise it will say file not found.还有一件事要记住,在 windows 上添加.exe
扩展名到末尾,否则会说找不到文件。 For eg: java.exe
on windows and java
on linux.例如: java.exe
上的 java.exe 和java
上的 java
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.