博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Node.js程序在node-windows中不能运行
阅读量:6170 次
发布时间:2019-06-21

本文共 1273 字,大约阅读时间需要 4 分钟。

 

Node.js程序部分功能在命令行中运行良好,但在node-windows中不能运行,怎么回事?

答:路径问题。

请看如下的描述:

My script runs fine on it's own, but not with node-windows. Why?

The most common reason for this type of behavior is the configuration of a path. For example, a lot of people use __dirname to define a path within their script without understanding __dirname is a relative path. It can and often does differ between a child and parent process. As the documentation suggests, it is always best to use absolute paths, not relative paths. Remember that node-windows spawns your script as a new child process, which is why the working directory is different from when you run node myscript.js. This is not specific to node-windows, this is the context most Windows background services run in.

Another common issue is a misunderstanding of how a third party module is used within an app. Some modules make assumptions about the context in which they're running. Make sure you understand what your third party modules are doing, don't just use them blindly. Running a node script as a daemon is very different from running as a server or worker.

原文:https://github.com/coreybutler/node-windows/wiki#my-script-runs-fine-on-its-own-but-not-with-node-windows-why

转载于:https://www.cnblogs.com/time-is-life/p/4602426.html

你可能感兴趣的文章
向上扩展型SSD 将可满足向外扩展需求
查看>>
用tar和split将文件分包压缩
查看>>
大数据传输,文件传输的专业解决方案!
查看>>
常用URL地址
查看>>
struts国际化
查看>>
数据库 : 事物以及隔离性导致的问题
查看>>
Jquery乱码终极解决方案
查看>>
Android Fragment 真正的完全解析(上) (转载)
查看>>
多线程依次打印abcabc
查看>>
一:学习Linux前准备工作
查看>>
how to install wireless driver for Dell 630 in Ubuntu
查看>>
Kafka 配置参数汇总及相关说明
查看>>
弄清 CSS3 的 transition 和 animation
查看>>
服务器指定网卡进行备份数据避免影响业务口
查看>>
在Sublime Text 2下面开发Sass
查看>>
四则运算个人项目3
查看>>
eclipse 构建maven web工程
查看>>
237. Delete Node in a Linked List
查看>>
[转] webpack之plugin内部运行机制
查看>>
宽字节与多字节之间的转换
查看>>