node.js app在本地运行正常,但不会以模数运行

时间:2015-05-29 07:23:06

标签: javascript node.js server modulus.io

起初,我在模数网站上发了一个帖子但是我认为它; s社区不是很活跃,所以这里包含的内容如下: 该应用程序,当我尝试加载它时,将在文档中说明其中任何一个:

未找到 要么 无法收集到任何应用程序实例。

在日志中,它说明了这一点,我真的不明白它。

_http_outgoing.js:335
throw new Error('Can\'t set headers after they are sent.');
^
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:335:11)
at Array.write (/mnt/app/node_modules/express/node_modules/finalhandler/index.js:115:9)
at listener (/mnt/app/node_modules/express/node_modules/on-finished/index.js:164:15)
at onFinish (/mnt/app/node_modules/express/node_modules/on-finished/index.js:95:5)
at callback (/mnt/app/node_modules/express/node_modules/on-finished/node_modules/ee-first/index.js:33:10)
at IncomingMessage.onevent (/mnt/app/node_modules/express/node_modules/on-finished/node_modules/ee-first/index.js:66:5)
at IncomingMessage.emit (events.js:104:17)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)

npm ERR! Linux 3.13.0-46-generic
npm ERR! argv "/mnt/home/.nvm/versions/node/v0.12.4/bin/node" "/mnt/home/.nvm/versions/node/v0.12.4/bin/npm" "start"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! code ELIFECYCLE
npm ERR! socket-Test@1.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the socket-Test@1.0.0 start script 'node server.js'.
npm ERR! This is most likely a problem with the socket-Test package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node server.js
npm ERR! You can get their info via:
npm ERR! npm owner ls socket-Test
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /mnt/app/npm-debug.log
Found package.json: ./package.json
Start script specified in package.json: node server.js
Initializing Node.js 0.12.4
Now using node v0.12.4
Running command: npm start

> socket-Test@1.0.0 start /mnt/app
> node server.js

listening on *:3000

这一切都以同样的方式完成了一个单独的项目,现在不起作用。任何建议或解决方案将不胜感激!

(顺便说一下我不确定这是否正常,但我注意到node_modules文件夹不在我的文件列表中,我不知道为什么,因为它在我的本地文件夹中)

然而,现在我已经到了日志所说的位置:

Found package.json: ./package.json
Start script specified in package.json: node server.js
Initializing Node.js 0.12.4
Now using node v0.12.4
Running command: npm start> Space-Wars@1.0.0 start /mnt/app> 
node server.js
listening on *:3000
Fri, 29 May 2015 07:07:06 GMT 
express deprecated res.sendfile: Use res.sendFile instead at server.js:9:6
Error: ENOENT, stat '/mnt/app/index.html'at Error (native)
Error: ENOENT, stat '/mnt/app/index.html'at Error (native)

我知道它正在寻找/ mnt / app中的文件,但我不知道为什么,它会在公共目录中找到所有内容;在本地运行。

我的文件树如下所示:

Public -[
- index.css
- index.js
- index.html
Server.js
node_modules (not included in server, I guess modulus installs based on package.json dependencies)
package.json

我使用此

绑定公用文件夹
app.use(express.static(path.join(__dirname, 'public')));

任何人都可以帮我解决这个问题,或者至少找不到问题。谢谢!!

1 个答案:

答案 0 :(得分:0)

我解决了这个问题,在表达中我用一个小写的公共'所以我将我的文件夹名称更改为public而不是Public。但是我仍然有点困惑,如果模数使用相同版本的node.js模块,为什么它不能处理模数'服务器