2017-11-29 2 views
0

axpress.js 솔루션을 실행하려고하면 문제가 발생하지만보기 폴더에서 index.jade 파일을 열면 브라우저에서 결과가 나타납니다 : "Welcome to Express", 하지만 클라이언트 디렉토리 -> index.html에있는 index.html 파일을 열고 싶습니다. npm을 실행하면이 위치에 액세스합니다 : http://localhost:3000/client/index.html,하지만이 해결책은 찾을 수 없습니다. app.js 파일에서Express.js는 index.html 파일을 열지 않습니다.

내가 경로 설정하고 정의

app.set('views', path.join(__dirname, 'views')); 
app.set('view engine', 'jade'); 

app.use(logger('dev')); 
app.use(bodyParser.json()); 
app.use(bodyParser.urlencoded({ extended: false })); 
app.use(cookieParser()); 
app.use(express.static(path.join(__dirname, 'public'))); 

app.use('/', routes); 
app.use('/users', users); 

루트 폴더를 :하는 index.js 파일 : 지금은 무엇입니까 때문에 내가 설정 내 라우팅이

var express = require('express'); 
var router = express.Router(); 

/* GET home page. */ 
router.get('/', function(req, res, next) { 
    res.render('index', { title: 'Express' }); 
}); 

module.exports = router; 

을 404.

+0

express.static는 'public'이라는 디렉토리를 제공하고 있으므로 거기에'index.html'을 넣어야합니다. – tladuke

+0

@tladuke 작동하지 않습니다. – BinaryTie

+0

현재 코드의 두 번째 줄에서 뷰 엔진을 Jade로 설정했습니다. 익스프레스는 현재'.jade' 확장 파일을 찾고 있습니다. –

답변

0

파일 이름을 index.html에서 index.jade로 변경하십시오.

+0

자세한 내용을 입력하십시오. –

+0

보기라는 새 디렉토리를 만들고이 html 파일을이 파일로 이동하고 jade를 템플릿 엔진으로 사용하고 있기 때문에 .html을 .jade로 변경하십시오. –

+0

작동하지 않습니다. – BinaryTie