【发布时间】:2019-12-28 01:07:18
【问题描述】:
我正在使用 Github 部署在 Heroku 上部署 Angular 5 应用程序。 Heroku 上的构建过程成功完成。 这是构建日志:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 9.0.0
engines.npm (package.json): 5.7.1
Resolving node version 9.0.0...
Downloading and installing node 9.0.0...
Bootstrapping npm 5.7.1 (replacing 5.5.1)...
npm 5.7.1 installed
-----> Restoring cache
Skipping cache restore (not-found)
-----> Building dependencies
Installing node modules (package.json + package-lock)
> uws@9.14.0 install /tmp/build_f955e847c7812f77225546f9f0519385/node_modules/uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0
> node-sass@4.8.3 install /tmp/build_f955e847c7812f77225546f9f0519385/node_modules/node-sass
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.8.3/linux-x64-59_binding.node
Download complete
Binary saved to /tmp/build_f955e847c7812f77225546f9f0519385/node_modules/node-sass/vendor/linux-x64-59/binding.node
Caching binary to /tmp/npmcache.6p2xH/node-sass/4.8.3/linux-x64-59_binding.node
> uglifyjs-webpack-plugin@0.4.6 postinstall /tmp/build_f955e847c7812f77225546f9f0519385/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js
> node-sass@4.8.3 postinstall /tmp/build_f955e847c7812f77225546f9f0519385/node_modules/node-sass
> node scripts/build.js
Binary found at /tmp/build_f955e847c7812f77225546f9f0519385/node_modules/node-sass/vendor/linux-x64-59/binding.node
Testing binary
Binary is fine
> puckgames@0.0.0 postinstall /tmp/build_f955e847c7812f77225546f9f0519385
> ng build --aot -prod
Date: 2018-05-01T12:51:14.033Z
Hash: bae98aa0ec3557461128
Time: 54842ms
chunk {0} polyfills.46af3f84a403e219371b.bundle.js (polyfills) 59.7 kB [initial] [rendered]
chunk {1} main.2c0ad66a3c04faa09c51.bundle.js (main) 393 kB [initial] [rendered]
chunk {2} styles.63956080a26a0ea45a51.bundle.css (styles) 48.1 kB [initial] [rendered]
chunk {3} inline.63bc67a6d5411e8cbf28.bundle.js (inline) 1.45 kB [entry] [rendered]
added 1502 packages from 1260 contributors in 105.406s
-----> Caching build
Clearing previous node cache
Saving 2 cacheDirectories (default):
- node_modules
- bower_components (nothing to cache)
-----> Pruning devDependencies
removed 1484 packages in 15.39s
-----> Build succeeded!
-----> Discovering process types
Procfile declares types -> (none)
Default types for buildpack -> web
-----> Compressing...
Done: 36.7M
-----> Launching...
Released v3
由于应用程序错误,我的应用程序从未运行。使用npm start 或heroku local web 时,应用在本地运行良好。
以下是应用中使用的版本:
- Angular 5.2.10
- npm 5.7.1
- 节点 9.0.0
我收到以下错误,不知道如何解决:
2018-05-01T12:52:03.421925+00:00 应用程序 [web.1]:npm 错误!退出状态 1 2018-05-01T12:52:03.422287+00:00 应用程序 [web.1]:npm 错误! 2018-05-01T12:52:03.422552+00:00 应用程序 [web.1]:npm 错误!失败了 puckgames@0.0.0 启动脚本。 2018-05-01T12:52:03.422819+00:00 应用[web.1]:npm 错误!这可能不是 npm 的问题。有 上面可能有额外的日志输出。 2018-05-01T12:52:03.431523+00:00 应用[web.1]: 2018-05-01T12:52:03.431832+00:00 应用程序 [web.1]:npm 错误!完整的日志 此运行的可在以下位置找到:2018-05-01T12:52:03.432041+00:00 应用 [web.1]:npm 错误!
/app/.npm/_logs/2018-05-01T12_52_03_424Z-debug.log 2018-05-01T12:52:03.482946+00:00 heroku[web.1]:进程退出 状态 1 2018-05-01T12:52:03.910224+00:00 heroku[路由器]: at=error 代码=H10 desc="应用程序崩溃" 方法=GET 路径="/" 主机=marcums-puck-games.herokuapp.com request_id=6e709bae-f4df-497f-89e9-ddd22b8f9230 fwd="66.41.188.175" dyno=连接=服务=状态=503字节=协议=https 2018-05-01T12:52:04.326950+00:00 heroku[路由器]: at=error code=H10 desc="应用程序崩溃" 方法=GET path="/favicon.ico" 主机=marcums-puck-games.herokuapp.com request_id=a45ab870-def7-422e-974a-1e25c16191bb fwd="66.41.188.175" dyno=连接=服务=状态=503字节=协议=https
server.js 文件
//Install express server
const express = require('express');
const path = require('path');
const app = express();
// Serve only the static files form the dist directory
app.use(express.static(__dirname + '/dist'));
app.get('/*', function(req,res) {
res.sendFile(path.join(__dirname+'/dist/index.html'));
});
// Start the app by listening on the default Heroku port
const port = process.env.PORT || 8080;
app.listen(port, () => {
console.log('Express server listening on port', port)
});
package.json 文件
{
"name": "puckgames",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "node server.js",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "ng build --aot -prod"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.10",
"@angular/cdk": "^5.2.5",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/flex-layout": "^5.0.0-beta.14",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/material": "^5.2.5",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19",
"typescript": "~2.5.3"
},
"devDependencies": {
"@angular/cli": "1.6.8",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
},
"engines": {
"node": "9.0.0",
"npm": "5.7.1"
}
}
所有帮助将不胜感激。如果我忽略了提供调试此部署所需的任何内容,请告诉我。感谢您的宝贵时间。
【问题讨论】:
标签: node.js angular heroku deployment angular5