Node.js 未定义nodejs服务器
我将使用nodemon start命令,但出现错误。你能帮我吗 ReferenceError:未定义服务器 app.js others.jsNode.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');
你在第四行有一个打字错误。您的模块名为“其他”。因此,在导入模块时,您应该使用
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);