[英]How can I place some of my Node.js files outside of my Node.js application root folder?
I want to put my Node unit tests in an application root level folder, /test/server/
. 我想将Node单元测试放在应用程序根目录文件夹
/test/server/
。 The problem is that when I put my Node files there, Node doesn't see my node_modules
. 问题是,当我将Node文件放在那里时,Node看不到
node_modules
。 My Node app is at /server/
. 我的Node应用程序位于
/server/
。
My app folder is structured like this: 我的应用文件夹的结构如下:
|- server/ (where my Node.js stuff is)
| |- package.json
| |- server.js
| |- etc
|- client/ (where my AngularJS and front-side stuff are)
| |- index.jade
| |- CSS/
| |- etc
|- test/ (where my unit tests are)
| |- server/
| |- client/
How can I solve this problem? 我怎么解决这个问题?
you need to set node path in your environment 您需要在您的环境中设置节点路径
NODE_PATH="/path/to/node_modules" NODE_PATH =“ / path / to / node_modules”
then you should be able to reference them 那么你应该可以参考他们
EDIT: Now that I had a second look at your require statement I see that you are specifying an extension for the module you are trying to require, remove that and you should be able to find the module 编辑:现在,我再次查看了您的require语句,我看到您正在为要尝试的模块指定扩展名,删除该扩展名,您应该能够找到该模块
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.