在linux上运行节点(express)会产生Error:spawn EACCES

jan*_*s86 14 ubuntu port node.js express

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

可悲的是,我在尝试在终端中运行应用程序时遇到以下错误:

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

Error: spawn EACCES
Run Code Online (Sandbox Code Playgroud)

我在3000端口运行,我正在使用sudo.我也尝试了root,我也玩了1024个阈值以上的不同端口.

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

  app.listen(3000);
Run Code Online (Sandbox Code Playgroud)

我是一个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);
Run Code Online (Sandbox Code Playgroud)

您可以通过安装来自行测试: npm install mediacenterjs

jan*_*s86 20

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

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

  sudo chmod -R a+rwx APPNAME/file
Run Code Online (Sandbox Code Playgroud)

  • 虽然这可能会解决一个问题,但它也会让每个人都有APPNAME WRITABLE,这对服务器来说是一个巨大的安全风险. (3认同)
  • 不需要写入权限.你只需要`chmod a + x/path/to/file` (2认同)