我在项目中有多个node.js文件。
服务器代码如下:
app.js
Hence abstract methods are not optional but mandatorily be overridden by a inheriting subclass
现在我在var express = require('express');
app.use(express.static(__dirname + '/node_modules'));
app.use("/css", express.static(__dirname + '/css'));
app.use("/js", express.static(__dirname + '/js'));
app.use("/routes", express.static(__dirname + '/routes'));
var aws_router = require('./routes/aws')(app);
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
server.listen(8080);
中有另一个文件aws.js
,它基本上包含数据库操作
aws.js
./routes
现在我收到了错误
" var express = require('express');
var AWS = require('aws-sdk');
var credentials = new AWS.SharedIniFileCredentials({profile: 'default'});
AWS.config.credentials = credentials;
/*more code here*/
"在Uncaught ReferenceError: require is not defined
的aws.js文件中为什么会这样?同样的定义也存在app.js中,它们都很好。
我错过了什么?