在linux上运行node(express)会产生Error:spawn EACCES [英] Running node (express) on linux produces Error: spawn EACCES

查看:1172
本文介绍了在linux上运行node(express)会产生Error:spawn EACCES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Expressjs构建一个节点应用程序,我试图在一个新安装的Ubuntu上运行我的节点应用程序(我刚刚安装了git和node v 0.10.19)。



可惜的是,尝试在终端中运行应用程序时出现以下错误:

 事件.js:72 
throw er; //未处理的'错误'事件

错误:spawn EACCES

m在3000端口上运行,我使用sudo。我也尝试过root,我也玩过不同的端口,高于1024阈值。



该应用程序只是基本的Expressjs,我使用默认方法打开应用程序套接字:

  app.listen(3000); 

我是一个Linux noob,所以任何帮助是赞赏。该应用程序在Windows上的工作原理很好。



基本服务器代码:

 code> 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 +'/视图');
app.setMaxListeners(100);
app.use(express.bodyParser());
app.use(express.methodOverride());
应用程序.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

解决方案

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



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

  sudo chmod -R a + rwx APPNAME / file 


I'm building a node app with using Expressjs and I'm trying to run my node app on a freshly installed Ubuntu (I just installed git and node v 0.10.19).

Sadly though, I'm getting the following error when trying to run the app in terminal:

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

Error: spawn EACCES

I'm running on port 3000 and I am using sudo. I also tried as root and I also played around with different ports above the 1024 threshold.

The app is just basic Expressjs and I'm using the default method for opening the app socket:

  app.listen(3000);

I'm a Linux noob so any help is appreciated. the app works just great on Windows by the way.

The basic server code:

    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);

You can test it out yourself by installing: npm install mediacenterjs

解决方案

I solved it by setting the file permissions correctly.

It works by settings read/write and execute permissions.

  sudo chmod -R a+rwx APPNAME/file

这篇关于在linux上运行node(express)会产生Error:spawn EACCES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆