Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 未定义nodejs服务器_Node.js_Ubuntu 18.04 - Fatal编程技术网

Node.js 未定义nodejs服务器

Node.js 未定义nodejs服务器,node.js,ubuntu-18.04,Node.js,Ubuntu 18.04,我将使用nodemon start命令,但出现错误。你能帮我吗 ReferenceError:未定义服务器 app.js others.js 你在第四行有一个打字错误。您的模块名为“其他”。因此,在导入模块时,您应该使用 var other = require('./other'); 相反,您正在使用 var other = require('./others'); // change others to other 你的最终app.js应该是 var fs = require('fs');

我将使用nodemon start命令,但出现错误。你能帮我吗

ReferenceError:未定义服务器

app.js others.js
你在第四行有一个打字错误。您的模块名为“其他”。因此,在导入模块时,您应该使用

var other = require('./other');
相反,您正在使用

var other = require('./others'); // change others to other
你的最终app.js应该是

var fs = require('fs');
var express = require('express');
var path = require('path');
var other = require('./other');


var app = express();

app.get('/index', other.index);
app.get('/', other.index);

app.listen(8006);
确保在项目中安装了express模块

代码中未定义变量
server


它应该是
app.listen(8006)

请分享你的软件包。json(脚本>开始)它是
app.listen(8006)
而不是
server.listen(8006)
var other = require('./others'); // change others to other
var fs = require('fs');
var express = require('express');
var path = require('path');
var other = require('./other');


var app = express();

app.get('/index', other.index);
app.get('/', other.index);

app.listen(8006);