2013-09-25 106 views
11

我正在使用Expressjs构建节点应用程序,我试图在新安装的Ubuntu上运行我的节点应用程序(我刚刚安装了git和node v 0.10。 19)。在Linux上运行节点(快速)产生错误:产卵EACCES

Events.js:72 
    throw er; // unhandled 'error' event 

Error: spawn EACCES 

我在端口3000上运行,我使用sudo:

不过不幸的是,我想,当在终端运行应用程序收到下面的错误。我也尝试了作为根,我也玩过1024以上的不同端口。

该应用程序只是基本Expressjs和我使用的默认方法用于打开应用插座:

app.listen(3000); 

我是一个Linux小白所以任何帮助表示赞赏。顺便说一下,该应用程序在Windows上工作得很好。

基本服务器代码:

var express = require('express') 
    , app = express() 
    , fs = require ('fs') 
    , lingua = require('lingua'); 

    process.env.NODE_ENV = 'development'; 

    app.configure(function(){ 
     app.set('view engine', 'jade'); 
     app.set('views', __dirname + '/views'); 
     app.setMaxListeners(100); 
     app.use(express.bodyParser()); 
     app.use(express.methodOverride()); 
     app.use(express.static(__dirname + '/public')); 
     app.use(express.favicon(__dirname + '/public/core/favicon.ico')); 
     app.use(lingua(app, { 
      defaultLocale: 'translation_', 
      storageKey: 'lang', 
      path: __dirname+'/public/translations/', 
      cookieOptions: { 
       httpOnly: false,   
       expires: new Date(Date.now(-1)), 
       secure: false 
      } 
     })); 
     app.use(app.router); 
     app.locals.pretty = true; 
    }); 

    app.configure('development', function(){ 
     app.enable('verbose errors'); 
     app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); 
    }); 

    app.configure('production', function(){ 
     app.disable('verbose errors'); 
     app.use(express.errorHandler()); 
    }); 

    require('./lib/routing/routing')(app,{ verbose: !module.parent }); 


    app.listen(3000); 

您可以通过安装测试一下自己:npm install mediacenterjs

+0

它仍然发生在'require(http).createServer(app).listen(3000)' – Plato

+0

现在测试:)请稍等片刻! – jansmolders86

+0

哦对不起,我忘了报价。我不能编辑我以前的评论了,但它应该是:require('http')。createServer(app).listen(3000)'。你不需要安装http,它的内置。 – Plato

回答

17

我通过正确设置文件权限解决它。

它通过设置读/写和执行权限工作。

sudo chmod -R a+rwx APPNAME/file 
+0

解决了文件写入时出现eaccess错误3的问题。阅读工作完美,但链上的文件夹权限不正确。 – gspatel

+3

虽然这可能会解决一个问题,但它也会使APPNAME可写入所有人,这在服务器上具有巨大的安全风险。 – gerasalus

+1

@gerasalus,你是对的,我改变了我的答案设置文件的权利。这也工作得很好。谢谢! – jansmolders86