Successfully deployed Angular app with proxy to Heroku but the web page displays Error Not Found
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have gone about deploying my angular app as I usually do but this time I get an Error Not Found. When I check Heroku logs the following message stands out...
Error: ENOENT: no such file or directory, stat '/app/dist/my-app/index.html'
My server.js file looks like this...
const express = require('express');
const app = express();
const path = require('path');
app.use(express.static(__dirname + '/dist/my-app'));
app.listen(process.env.PORT || 8080);
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname + '/dist/my-app/index.html'));
});
console.log('Node-express server listening!');
I moved @angluar/cli
and @angular/compiler-cli
as well as typescript
from the devDependencies and into dependencies object as usual. Here's my package.json..
{
"name": "my-app",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "node server.js --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "ng build --aot --prod"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.0.4",
"@angular/cdk": "^7.0.4",
"@angular/cli": "^7.0.6",
"@angular/common": "^7.0.4",
"@angular/compiler": "^7.0.4",
"@angular/compiler-cli": "^7.0.4",
"@angular/core": "^7.0.4",
"@angular/flex-layout": "^7.0.0-beta.19",
"@angular/forms": "^7.0.4",
"@angular/http": "^7.0.4",
"@angular/material": "^7.0.4",
"@angular/platform-browser": "^7.0.4",
"@angular/platform-browser-dynamic": "^7.0.4",
"@angular/router": "^7.0.4",
"core-js": "^2.5.7",
"express": "^4.16.4",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"ngx-gallery": "^5.9.0",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3",
"typescript": "^3.1.6",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.10.6",
"@angular/language-service": "^7.0.4",
"@types/jasmine": "~3.3.0",
"@types/jasminewd2": "~2.0.6",
"@types/node": "~10.12.9",
"codelyzer": "~4.5.0",
"jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "^5.4.1",
"ts-node": "~7.0.1",
"tslint": "~5.11.0"
},
"engines": {
"node": "10.10.0",
"npm": "6.4.1"
}
}
The only difference this time comes in the scripts
object where instead of the usual "start": "node server.js"
, I have "start": "node server.js --proxy-config proxy.conf.json"
Locally the project compiles and runs with "start": "ng serve --proxy-config proxy.conf.json"
.
I have also checked for any missing files or folders by heroku run bash
and then dir
. Everything seems to be fine.
I have built and deployed angular apps to heroku multiple times before. The only difference I can find this time, is that I am using a proxy to connect to a back end. Am I doing something wrong? Any help would be nice.
node.js angular heroku
add a comment |
I have gone about deploying my angular app as I usually do but this time I get an Error Not Found. When I check Heroku logs the following message stands out...
Error: ENOENT: no such file or directory, stat '/app/dist/my-app/index.html'
My server.js file looks like this...
const express = require('express');
const app = express();
const path = require('path');
app.use(express.static(__dirname + '/dist/my-app'));
app.listen(process.env.PORT || 8080);
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname + '/dist/my-app/index.html'));
});
console.log('Node-express server listening!');
I moved @angluar/cli
and @angular/compiler-cli
as well as typescript
from the devDependencies and into dependencies object as usual. Here's my package.json..
{
"name": "my-app",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "node server.js --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "ng build --aot --prod"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.0.4",
"@angular/cdk": "^7.0.4",
"@angular/cli": "^7.0.6",
"@angular/common": "^7.0.4",
"@angular/compiler": "^7.0.4",
"@angular/compiler-cli": "^7.0.4",
"@angular/core": "^7.0.4",
"@angular/flex-layout": "^7.0.0-beta.19",
"@angular/forms": "^7.0.4",
"@angular/http": "^7.0.4",
"@angular/material": "^7.0.4",
"@angular/platform-browser": "^7.0.4",
"@angular/platform-browser-dynamic": "^7.0.4",
"@angular/router": "^7.0.4",
"core-js": "^2.5.7",
"express": "^4.16.4",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"ngx-gallery": "^5.9.0",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3",
"typescript": "^3.1.6",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.10.6",
"@angular/language-service": "^7.0.4",
"@types/jasmine": "~3.3.0",
"@types/jasminewd2": "~2.0.6",
"@types/node": "~10.12.9",
"codelyzer": "~4.5.0",
"jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "^5.4.1",
"ts-node": "~7.0.1",
"tslint": "~5.11.0"
},
"engines": {
"node": "10.10.0",
"npm": "6.4.1"
}
}
The only difference this time comes in the scripts
object where instead of the usual "start": "node server.js"
, I have "start": "node server.js --proxy-config proxy.conf.json"
Locally the project compiles and runs with "start": "ng serve --proxy-config proxy.conf.json"
.
I have also checked for any missing files or folders by heroku run bash
and then dir
. Everything seems to be fine.
I have built and deployed angular apps to heroku multiple times before. The only difference I can find this time, is that I am using a proxy to connect to a back end. Am I doing something wrong? Any help would be nice.
node.js angular heroku
add a comment |
I have gone about deploying my angular app as I usually do but this time I get an Error Not Found. When I check Heroku logs the following message stands out...
Error: ENOENT: no such file or directory, stat '/app/dist/my-app/index.html'
My server.js file looks like this...
const express = require('express');
const app = express();
const path = require('path');
app.use(express.static(__dirname + '/dist/my-app'));
app.listen(process.env.PORT || 8080);
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname + '/dist/my-app/index.html'));
});
console.log('Node-express server listening!');
I moved @angluar/cli
and @angular/compiler-cli
as well as typescript
from the devDependencies and into dependencies object as usual. Here's my package.json..
{
"name": "my-app",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "node server.js --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "ng build --aot --prod"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.0.4",
"@angular/cdk": "^7.0.4",
"@angular/cli": "^7.0.6",
"@angular/common": "^7.0.4",
"@angular/compiler": "^7.0.4",
"@angular/compiler-cli": "^7.0.4",
"@angular/core": "^7.0.4",
"@angular/flex-layout": "^7.0.0-beta.19",
"@angular/forms": "^7.0.4",
"@angular/http": "^7.0.4",
"@angular/material": "^7.0.4",
"@angular/platform-browser": "^7.0.4",
"@angular/platform-browser-dynamic": "^7.0.4",
"@angular/router": "^7.0.4",
"core-js": "^2.5.7",
"express": "^4.16.4",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"ngx-gallery": "^5.9.0",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3",
"typescript": "^3.1.6",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.10.6",
"@angular/language-service": "^7.0.4",
"@types/jasmine": "~3.3.0",
"@types/jasminewd2": "~2.0.6",
"@types/node": "~10.12.9",
"codelyzer": "~4.5.0",
"jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "^5.4.1",
"ts-node": "~7.0.1",
"tslint": "~5.11.0"
},
"engines": {
"node": "10.10.0",
"npm": "6.4.1"
}
}
The only difference this time comes in the scripts
object where instead of the usual "start": "node server.js"
, I have "start": "node server.js --proxy-config proxy.conf.json"
Locally the project compiles and runs with "start": "ng serve --proxy-config proxy.conf.json"
.
I have also checked for any missing files or folders by heroku run bash
and then dir
. Everything seems to be fine.
I have built and deployed angular apps to heroku multiple times before. The only difference I can find this time, is that I am using a proxy to connect to a back end. Am I doing something wrong? Any help would be nice.
node.js angular heroku
I have gone about deploying my angular app as I usually do but this time I get an Error Not Found. When I check Heroku logs the following message stands out...
Error: ENOENT: no such file or directory, stat '/app/dist/my-app/index.html'
My server.js file looks like this...
const express = require('express');
const app = express();
const path = require('path');
app.use(express.static(__dirname + '/dist/my-app'));
app.listen(process.env.PORT || 8080);
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname + '/dist/my-app/index.html'));
});
console.log('Node-express server listening!');
I moved @angluar/cli
and @angular/compiler-cli
as well as typescript
from the devDependencies and into dependencies object as usual. Here's my package.json..
{
"name": "my-app",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "node server.js --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "ng build --aot --prod"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.0.4",
"@angular/cdk": "^7.0.4",
"@angular/cli": "^7.0.6",
"@angular/common": "^7.0.4",
"@angular/compiler": "^7.0.4",
"@angular/compiler-cli": "^7.0.4",
"@angular/core": "^7.0.4",
"@angular/flex-layout": "^7.0.0-beta.19",
"@angular/forms": "^7.0.4",
"@angular/http": "^7.0.4",
"@angular/material": "^7.0.4",
"@angular/platform-browser": "^7.0.4",
"@angular/platform-browser-dynamic": "^7.0.4",
"@angular/router": "^7.0.4",
"core-js": "^2.5.7",
"express": "^4.16.4",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"ngx-gallery": "^5.9.0",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3",
"typescript": "^3.1.6",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.10.6",
"@angular/language-service": "^7.0.4",
"@types/jasmine": "~3.3.0",
"@types/jasminewd2": "~2.0.6",
"@types/node": "~10.12.9",
"codelyzer": "~4.5.0",
"jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "^5.4.1",
"ts-node": "~7.0.1",
"tslint": "~5.11.0"
},
"engines": {
"node": "10.10.0",
"npm": "6.4.1"
}
}
The only difference this time comes in the scripts
object where instead of the usual "start": "node server.js"
, I have "start": "node server.js --proxy-config proxy.conf.json"
Locally the project compiles and runs with "start": "ng serve --proxy-config proxy.conf.json"
.
I have also checked for any missing files or folders by heroku run bash
and then dir
. Everything seems to be fine.
I have built and deployed angular apps to heroku multiple times before. The only difference I can find this time, is that I am using a proxy to connect to a back end. Am I doing something wrong? Any help would be nice.
node.js angular heroku
node.js angular heroku
asked Nov 29 '18 at 6:15
Nelson KingNelson King
1068
1068
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53532892%2fsuccessfully-deployed-angular-app-with-proxy-to-heroku-but-the-web-page-displays%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53532892%2fsuccessfully-deployed-angular-app-with-proxy-to-heroku-but-the-web-page-displays%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown