简体   繁体   English

使用.desktop文件在树莓派上启动node.js终端应用程序

[英]Launch a node.js terminal application on a raspberry pi with a .desktop file

Soo... I thought this would be a easy task. 太...我认为这将是一件容易的事。 Create a .desktop file that launch my node.js app and thats it... Nope. 创建一个.desktop文件,启动我的node.js应用,就这样...不。 My .desktop file looks like this: 我的.desktop文件如下所示:

[Desktop Entry]
Name=NodeJS App
Comment=My comment
Exec=lxterminal -t "NodeJS App" --working-directory=/path/to/app -e nameOfMyApp
Type=Application
Encoding=UTF-8
Terminal=true
Categories=None;

I also tried other ways to launch the app. 我还尝试了其他启动应用程序的方法。 I also tried out to launch my app with a python script. 我还尝试了使用python脚本启动我的应用程序。 No chance. 没有机会。 The Terminal stays empty and it does nothing. 终端保持为空,它什么也不做。

It works fine when I open the terminal, go to the app folder and launch the app. 当我打开终端,转到应用程序文件夹并启动应用程序时,它工作正常。 What's wrong? 怎么了? Is there another way? 还有另一种方法吗? The app runs on a raspberry pi with touchscreen as only way to control it. 该应用程序在带有触摸屏的树莓派上运行,这是控制它的唯一方法。 So it must be a solution where the user just need to open a file on the desktop. 因此,它必须是用户只需要在桌面上打开文件的解决方案。

Here is the solution. 这是解决方案。 I installed node with the help of nvm. 我在nvm的帮助下安装了node。 Using lxterminal like this will not add nvm as source. 像这样使用lxterminal不会将nvm添加为源。 So the terminal can't find node or npm. 因此终端无法找到节点或npm。

This command must be fired before I start a node app: 在启动节点应用程序之前,必须先触发以下命令:

source ~/.nvm/nvm.sh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM