0
I can route in the Node where it calls an html page, but the html page has a file. js and when it is called the error of not finding the JS file.
Can someone help me?
Structure:
main folder : project
subdirectories: config, js, views
within config:config.js within js: request.js within views: index.html
config.js:
var express = require('express');
var port = 3000;
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extend : true}));
app.use(bodyParser.json());
app.listen(port);
app.set('views', './views');
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'ejs');
app.use('/public', express.static(__dirname + '/views/'));
module.exports.express = function(){
return app;
}
app.js(is located in the main folder):
var app = require('./config/config.js').express();
app.get('/',function(req,res){
res.render('index.html');
});
Post your Node, html and folder structure
– Felipe Duarte
See if it helps, I edited
– rods
That one
arquivo.js
is a file to run on the server or to be called from HTML and run in the browser?– Sergio