Node.js程序在node-windows中不能运行
2015-06-26 15:44
651 查看
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. |
相关文章推荐
- node 安装socket.io
- nodejs npm常用命令
- Nodejs Request使用介绍
- ENode框架使用场景简述
- node mysql 连接池
- NodeJs Debug小工具的使用
- node.js 初体验
- webstorm配置node.js
- Leetcode#19 Remove Nth Node From End of List
- windows下nodejs环境配置
- [leetcode] Populating Next Right Pointers in Each Node II
- 《 Node.js项目实践:构建可扩展的Web应用》试读
- [leetcode] Populating Next Right Pointers in Each Node
- Node API
- 配置ssh时sshd不能启动解决办法
- Node.js学习
- NodeJs 开发者最常犯的10个错误(一)
- node mysql 链接
- leetcode-24Swap Nodes in Pairs
- LintCode Nth to Last Node in List 链表倒数第n个节点