我正在尝试在heroku上部署我的angular 4应用程序,但它无法正确地进行操作。在当地所有工作都按预期正常。
这里有文件:
的package.json
{
"name": "webcli2",
"version": "0.0.0",
"license": "MIT",
"main": "app.js",
"scripts": {
"ng": "ng",
"start": "node app.js",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "ng build --aot --target=production"
},
"engines": {
"node": "6.11.3",
"npm": "3.10.10"
},
"private": true,
"dependencies": {
"@angular/animations": "4.2.4",
"@angular/cli": "1.4.3",
"@angular/common": "4.2.4",
"@angular/compiler": "4.2.4",
"@angular/compiler-cli": "4.2.4",
"@angular/core": "4.2.4",
"@angular/forms": "4.2.4",
"@angular/http": "4.2.4",
"@angular/platform-browser": "4.2.4",
"@angular/platform-browser-dynamic": "4.2.4",
"@angular/router": "4.2.4",
"@auth0/angular-jwt": "1.0.0-beta.9",
"bootstrap": "3.3.7",
"core-js": "2.4.1",
"express": "4.16.2",
"grunt": "1.0.1",
"grunt-cli": "1.2.0",
"grunt-contrib-sass": "*",
"grunt-contrib-watch": "*",
"ngx-bootstrap": "1.9.3",
"rxjs": "5.4.2",
"vue-carousel-3d": "0.1.18",
"zone.js": "0.8.14",
"typescript": "2.3.3"
},
"devDependencies": {
...
}
app.js
const express = require('express');
const app = express();
const path = require('path');
app.use(express.static(path.join(__dirname,'dist')));
app.listen(process.env.PORT || 8080);
app.get('/*', function (req,res) => {
res.sendFile(path.join(__dirname,'/dist/index.html'));
});
console.log('console listening');
Procfile web:npm start
关于错误:我得到了这个:
remote: @angular/compiler-cli@4.4.6 requires typescript@'>=2.1.0 <2.4.0' but 2.6.1 was found instead.
remote: Using this version can result in undefined behaviour and difficult to debug problems.
remote:
remote: Please run the following command to install a compatible version of TypeScript.
remote:
remote: npm install typescript@'>=2.1.0 <2.4.0'
remote:
remote: To disable this warning run "ng set --global warnings.typescriptMismatch=false".
remote:
remote: 11% building modules 13/13 modules 0 activeTemplate parse warnings:
remote: The <template> element is deprecated. Use <ng-template> instead ("
remote: [WARNING ->]<template [ngIf]="!isClosed">
remote: <div [class]="'alert alert-' + type" role="alert" [ngClass]="classes""): ng:///tmp/build_1e53727d0184bdda3a3ece784898bf98/node_modules/ngx-bootstrap/alert/alert.component.d.ts.AlertComponent.html@1:0
remote: Warning: Can't resolve all parameters for ApplicationError in /tmp/build_1e53727d0184bdda3a3ece784898bf98/src/app/util/applicationError.service.ts: (?). This will become an error in Angular v5.x
remote: Warning: Can't resolve all parameters for ApplicationError in /tmp/ build_1e53727d0184bdda3a3ece784898bf98/src/app/util/applicationError.service.ts: (?). This will become an error in Angular v5.x
Date: 2017-11-14T10:33:21.586Z
remote: Hash: 5582f12f0052b6c3a94c
remote: Time: 22622ms
remote: chunk {0} styles.de3b0b246fb3804809f9.bundle.css (styles) 133 kB {3} [initial] [rendered]
remote: chunk {1} polyfills.3bc34265385d52184eab.bundle.js (polyfills) 86 bytes {3} [initial] [rendered]
remote: chunk {2} main.e402deade8b026b7d50e.bundle.js (main) 84 bytes [initial] [rendered]
remote: chunk {3} inline.ebdb3a382088c7f31aee.bundle.js (inline) 1.45 kB [entry] [rendered]
remote:
remote: ERROR in /tmp/build_1e53727d0184bdda3a3ece784898bf98/src/app/services/auth/user/user.service.ts (73,75): Value of type '() => any' has no properties in common with type '{ headers?: HttpHeaders; observe?: "body"; params?: HttpParams; reportProgress?: boolean; respons...'. Did you mean to call it?
remote: ERROR in /tmp/build_1e53727d0184bdda3a3ece784898bf98/src/app/services/auth/user/user.service.ts (82,39): Type 'Headers' has no properties in common with type 'RequestOptionsArgs'.
remote: ERROR in /tmp/build_1e53727d0184bdda3a3ece784898bf98/src/app/services/auth/auth.service.ts (16,34): Cannot find module '../../util/applicationerror.service'.
remote: ERROR in /tmp/build_1e53727d0184bdda3a3ece784898bf98/src/app/services/auth/auth.service.ts (111,5): Type 'Observable<void | {}>' is not assignable to type 'Observable<{}>'.
remote: Type 'void | {}' is not assignable to type '{}'.
remote: Type 'void' is not assignable to type '{}'.
remote:
remote: npm ERR! Linux 3.13.0-133-generic
remote: npm ERR! argv "/tmp/build_1e53727d0184bdda3a3ece784898bf98/.heroku/ node/bin/node" "/tmp/build_1e53727d0184bdda3a3ece784898bf98/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/ build_1e53727d0184bdda3a3ece784898bf98/.npmrc"
remote: npm ERR! node v6.11.3
remote: npm ERR! npm v3.10.10
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! webcli2@0.0.0 postinstall: `ng build --aot --target=production`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the webcli2@0.0.0 postinstall script 'ng build --aot --target=production'.
remote: npm ERR! Make sure you have the latest version of node.js and npm installed.
remote: npm ERR! If you do, this is most likely a problem with the webcli2 package,
remote: npm ERR! not with npm itself.
remote: npm ERR! Tell the author that this fails on your system:
remote: npm ERR! ng build --aot --target=production
remote: npm ERR! You can get information on how to open an issue for this project with:
remote: npm ERR! npm bugs webcli2
remote: npm ERR! Or if that isn't available, you can get their info via:
remote: npm ERR! npm owner ls webcli2
remote: npm ERR! There is likely additional logging output above.
remote:
remote: npm ERR! Please include the following file with any support request:
remote: npm ERR! /tmp/build_1e53727d0184bdda3a3ece784898bf98/npm-debug.log
remote:
remote: -----> Build failed
所以看起来它无法安装以前的打字稿版本,在这种情况下,heroku已经是2.6.1了,但我在文件上的那个是2.3.3
这是导致此错误的原因?
当地我得到了:
Brunos-MBP:webcli brunolopes$ ng build -aot
12% building modules 18/18 modules 0 activeWarning: Can't resolve all
parameters for ApplicationError in
/Users/brunolopes/development/workspace2016/
webroot/winpi/webcli/src/app/util/applicationerror.service.ts: (?). This will become an error in Angular v5.x
Warning: Can't resolve all parameters for ApplicationError in
/Users/brunolopes/development/workspace2016/
webroot/winpi/webcli/src/app/util/applicationerror.service.ts: (?). This will become an error in Angular
v5.x
Template parse warnings:
The <template> element is deprecated. Use <ng-template> instead ("
[WARNING ->]<template [ngIf]="!isClosed">
<div [class]="'alert alert-' + type" role="alert" [ngClass]="classes""): ng:///Users/brunolopes/development/workspace2016/webroot/winpi/webcli/node_modules/ngx-bootstrap/alert/alert.component.d.ts.AlertComponent.html@1:0
Date: 2017-11-16T07:51:16.467Z
Hash: 32f3a3b7f72daf78e799
Time: 53961ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB
[entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 515 kB {vendor}
[initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map
(polyfills)
217 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 153 kB
{inline} [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.43 MB
[initial] [rendered]
Brunos-MBP:webcli brunolopes$
由于
乙
答案 0 :(得分:0)
我已将角度版本更改为4.4.6并解决了该问题。
这是我本地环境中的错误,我在package.json上有4.2.4。
全部谢谢!