gpt4 book ai didi

node.js - 在 linux 上运行 node (express) 产生错误 : spawn EACCES

转载 作者:IT老高 更新时间:2023-10-28 23:10:13 24 4
gpt4 key购买 nike

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

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

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

Error: spawn EACCES

我在 3000 端口上运行,我正在使用 sudo。我也尝试过以 root 身份使用,并且还使用了高于 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

最佳答案

我通过正确设置文件权限解决了这个问题。

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

  sudo chmod -R a+rwx APPNAME/file

关于node.js - 在 linux 上运行 node (express) 产生错误 : spawn EACCES,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19009778/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com