2017-09-09 1 views
0

Heroku에서 angular4 앱을 배포하려고합니다. 하지만 내 .html에서 연결된 모든 .js 참조에 오류가 발생합니다.Heroku에서 Angular2를 배포하면 모든 외부 참조에서 'Uncaught SyntaxError : Unexpected Token <'이 발생합니다.

오류는 같은

이러한 모든 파일 내 src/client/assets/js/ 디렉토리에 존재
16:29:54.613 myapp.herokuapp.com/:1 Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://myapp.herokuapp.com/assets/style/bootstrap.css". 
16:29:54.646 jquery-1.10.2.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:54.647 myapp.herokuapp.com/:1 Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://myapp.herokuapp.com/styles.d41d8cd98f00b204e980.bundle.css". 
16:29:54.685 bootstrap.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:54.743 jquery.bxslider.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:54.744 jquery.centralized.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:54.776 jquery.fixedonlater.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:54.865 jquery.hashloader.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:54.867 jquery.mixitup.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:54.868 jquery.nav.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:54.869 jquery.parallax-1.1.3.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:54.946 jquery.responsivevideos.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:54.947 jquery.scrollTo.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:54.948 jquery.tweet.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:54.999 jquery.tweetCarousel.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:55.001 holder.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:55.003 application.min.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:55.005 inline.230e19a62ca0cc6cf333.bundle.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:55.007 polyfills.2a6cee40ee8af30fbaec.bundle.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:55.018 vendor.20becde8ac8acd1f3058.bundle.js:1 Uncaught SyntaxError: Unexpected token < 
16:29:55.019 main.f037d06044d7934ea073.bundle.js:1 Uncaught SyntaxError: Unexpected token < 

과 같습니다. 내 server.js

const express = require('express'); 
const path = require('path'); 

const root = './dist/public'; 
const pub = process.env.PUBLIC || `${root}`; 
const app = express(); 

app.use(express.static(path.join(__dirname, 'dist/public/assets'))); 
app.use(express.static(path.join(__dirname, 'dist/public'))); 

app.get('/*', (req, res) => { 
    res.sendFile(`index.html`, { root: pub }); 
}); 

const port = process.env.PORT || 3000; 
app.set('port', port); 
app.listen(port,() => console.log(`API running on localhost:${port}`)); 

내가 실종 무언가로 무엇입니까? 응용 프로그램은 로컬에서 잘 작동합니다.

+1

'text/html'과'예기치 않은 토큰 < '을 모두 고려해 볼 수는 없지만 모든 리소스가 HTML 컨텐트로 제공되고 있다고 생각할 수는 없습니다. 전선을 통해 들어오는 파일의 내용을 살펴보십시오. 그것들은 에러 페이지 일지 모르지만'express.static'가 파일을 찾지 못하기 때문에'index.html'의 모든 복사본이 제공 될 가능성이 더 높습니다. – skirtle

+0

그것은 흥미로운 일입니다. 크롬 개발자 도구에서'sources' 파일을 열면 각 파일 소스가 열리고 내 index.html과 똑같이 생깁니다. – gh0st

+0

아마'app.get ('/ *')'는 내'index.html' 만 리턴하고 있습니까? 내 '자산'에있는 것 대신에 ?? – gh0st

답변

0

이것은 내 dyno가 내 스크립트를 실행하는 파일 위치와 관련이있었습니다. 내 server.js에 대한 참조가 필요했던 내 server.js의 모든 파일이 '정적으로'게재되었습니다.

관련 문제