Is there any way to create an shortcut desktop to a Node.js (npm) application?

那年仲夏 提交于 2020-01-14 13:25:26

问题


Inexperienced users want to "see" the app that I've created in Node.js, but they don't want to use the console. According to them, it's a good idea to install it, and with a simple click, in desktop, they could "see" it.

They want to run the Node.js app as a Windows program. That's all!

How can I do it? Should I create a batch file?


回答1:


**SOLVED**

An .bat file, renamed as "appstart.bat"

cd C:\Users\MyUser\MyApp
npm start

With shortcut in desktop.




回答2:


The bat file should look like the below

cd folder directory
node file.js

Example:

cd users\me\documents\mynodeproject\
node index.js

When you click the bat file shortcut it will open the node command prompt and your console app will launch.




回答3:


You can also create a shortcut and set "Target" to...

C:\Windows\System32\cmd.exe /k "node index.js""

... and set "Start In" to the directory index.js is in.



来源:https://stackoverflow.com/questions/39512375/is-there-any-way-to-create-an-shortcut-desktop-to-a-node-js-npm-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!