Heroku部署失败:sh:1:ng:找不到

时间:2019-02-09 08:44:13

标签: node.js heroku angular7

Heroku部署失败。一直在寻找其他类似的堆栈溢出帖子并更改package.json文件,尝试对其他运气不好的解决方案。我不确定这是端口问题还是package.json问题或完全不同的问题。任何帮助,技巧或建议,我们将不胜感激!

<body onload="delayedAlert();">

<script>

var timeoutID;

function delayedAlert() {
  timeoutID = window.setTimeout(slowAlert, 50);
}

function slowAlert() {
 var audio= document.getElementsByTagName('audio')[0];
 const audio2 = document.getElementsByTagName('audio')[1];
 var audio3 = document.getElementsByTagName('audio')[2];
  var audio4 = document.getElementsByTagName('audio')[3];

audio.play(); 
var myvar1;alert('Hello?');

audio2.play(); 
var myvar1;alert('Is something here?');

audio3.play();
var myvar2;alert('Something is here.');

audio4.play();

const name = prompt('What is your name?')

const sentence = 'Hello,' + name +'I am Eve'+name+name+name+name+'What does a' +name +' look like?';
responsiveVoice.speak(sentence, "US English Female", {
    rate: 0.4,
  onend: function() {
    // Redirect after sentence has been spoke
    location.replace('https://www.eves.website/eve_2.html');
  }
});
};


</script>

 <audio>
  <source src="audio/hello.wav" type="audio/wav" preload=true>
 </audio>

 <audio>
  <source src="audio/is_something_here.wav" type="audio/wav" preload=true>
 </audio>

  <audio>
  <source src="audio/oh_something_is_here.wav" type="audio/wav" preload=true>
 </audio>


 <audio>
 <source src="audio/what_is_your_name.wav" type="audio/wav" preload=true>
 </audio>



        <video autoplay="autoplay" preload="auto" id="video" src="images/evetwo.mp4" width="1300px" height="auto" style="position:absolute; z-index:-1;" >
        Video not supported.
         </video>






</body>
</html>

server.js文件

Heroku logs: 

2019-02-09T08:32:56.609533+00:00 heroku[web.1]: State changed from crashed to starting
2019-02-09T08:33:00.956199+00:00 heroku[web.1]: Starting process with command `npm start`
2019-02-09T08:33:03.430137+00:00 heroku[web.1]: State changed from starting to crashed
2019-02-09T08:33:03.257739+00:00 app[web.1]: 
2019-02-09T08:33:03.257781+00:00 app[web.1]: > the-lottery-genie-mean@0.0.0 start /app
2019-02-09T08:33:03.257783+00:00 app[web.1]: > ng serve
2019-02-09T08:33:03.257784+00:00 app[web.1]: 
2019-02-09T08:33:03.294426+00:00 app[web.1]: sh: 1: ng: not found
2019-02-09T08:33:03.304958+00:00 app[web.1]: npm ERR! file sh
2019-02-09T08:33:03.305986+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-02-09T08:33:03.306367+00:00 app[web.1]: npm ERR! errno ENOENT
2019-02-09T08:33:03.309015+00:00 app[web.1]: npm ERR! syscall spawn
2019-02-09T08:33:03.310700+00:00 app[web.1]: npm ERR! the-lottery-genie-mean@0.0.0 start: `ng serve`
2019-02-09T08:33:03.310912+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-02-09T08:33:03.311266+00:00 app[web.1]: npm ERR! 
2019-02-09T08:33:03.311514+00:00 app[web.1]: npm ERR! Failed at the the-lottery-genie-mean@0.0.0 start script.
2019-02-09T08:33:03.314421+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-02-09T08:33:03.324652+00:00 app[web.1]: 
2019-02-09T08:33:03.324892+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-02-09T08:33:03.325013+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-02-09T08_33_03_316Z-debug.log
2019-02-09T08:33:03.411224+00:00 heroku[web.1]: Process exited with status 1 

package.json: 

{
  "name": "the-lottery-genie-mean",
  "version": "0.0.0",
  "scripts": {
    "preinstall": "npm link @angular/cli ",
    "heroku-postbuild": "ng build --prod",
    "postinstall": "",
    "ng": "ng",
    "start": "node server.js",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/cli": "^7.1.4",
    "@angular/compiler-cli": "~7.0.0",
    "@angular/animations": "~7.0.0",
    "@angular/common": "~7.0.0",
    "@angular/compiler": "~7.0.0",
    "@angular/core": "~7.0.0",
    "@angular/forms": "~7.0.0",
    "@angular/http": "~7.0.0",
    "@angular/platform-browser": "~7.0.0",
    "@angular/platform-browser-dynamic": "~7.0.0",
    "@angular/router": "~7.0.0",
    "core-js": "^2.5.4",
    "json": "^9.0.6",
    "rxjs": "~6.3.3",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.13.1",
    "@angular/language-service": "~7.0.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.1.1"
  },
  "engines": {
    "node": "10.15.1",
    "npm": "6.4.1"
  }
}

})

4 个答案:

答案 0 :(得分:1)

您是否在/app/.npm/_logs/2019-02-09T08_33_03_316Z-debug.log处检查了调试日志?

我建议先查看调试日志,以获取更多详细信息来解决问题。

更新

Its an H10 error. "heroku[router]: at=error code=H10 desc="App crashed"
method=GET path="/favicon.ico" host=angular-lottery-genie.herokuapp.com
request_id=30e63a79-c395-4d2a-9987-938bcc350629 fwd="50.250.113.70" dyno=
connect= service= status=503 bytes= protocol=https"

您的应用崩溃了。您可以执行以下操作:

1。)重新启动heroku。您应该已安装heroku CLI。这是链接:Heroku CLI Install。然后在您的终端上运行heroku restart

2。)使用Heroku动态设置的端口(通常可以在process.env.PORT进行访问),并将所需的端口设置为备份端口:

app.listen(process.env.PORT || 3000, function(){
  console.log("Node app is running at localhost:" + app.get('port'));
});

3。)尝试通过输入终端来检查您的nodenpm版本:

node --version
npm --version

并更新package.json文件下指示的nodenpm版本:

"engines": {
  "node": "10.15.1",
  "npm": "6.4.1"
}

您的问题的另一个更新:

npm ERR! enoent ENOENT: no such file or directory

这些错误通常与软件包损坏或不兼容有关。您可以做什么:

1。)确保backgound中没有其他节点实例在运行,然后重试您的npm命令。

2。)删除node_modules目录和package-lock.json(如果有)。在项目目录内的终端中重新安装运行npm install的软件包(或用于安装软件包的任何命令)。

3。)将节点升级到最新版本,删除node_modules目录和package-lock.json,然后重新安装软件包。

4。)如果npm仍然不适合您,请尝试使用yarn软件包管理器(Yarn)。

5。)如果软件包安装仍然失败,请检查错误日志文件以获取有关错误的详细报告。

希望这会有所帮助!

答案 1 :(得分:0)

您可能需要添加devkit / builder,并确保其顺序正确。我以粗体添加了它,因此请确保您是否要复制粘贴以从头到尾删除星号。

"@angular/cli": "^7.1.4",
"@angular/compiler-cli": "~7.0.0",
"@angular/animations": "~7.0.0",
"@angular/common": "~7.0.0",
"@angular/compiler": "~7.0.0",
"@angular/core": "~7.0.0",
"@angular/forms": "~7.0.0",
"@angular/http": "~7.0.0",
"@angular/platform-browser": "~7.0.0",
"@angular/platform-browser-dynamic": "~7.0.0",
"@angular/router": "~7.0.0",
**"@angular-devkit/build-angular": "^0.13.1",
"@angular/language-service": "~7.0.0",**
"core-js": "^2.5.4",
"json": "^9.0.6",
"rxjs": "~6.3.3",
"zone.js": "~0.8.26"

答案 2 :(得分:0)

将一些devDependencies移到dependencies(角度9示例)

 npm i @angular/cli @angular-devkit/build-angular @angular/compiler-cli typescript --save-prod

或将NPM_CONFIG_PRODUCTION设置为false

here是对类似问题的答案

答案 3 :(得分:0)

根据我的经验,在Heroku中部署在本地运行的应用程序并不总是那么简单。在StackOverflow中,有几种此类情况没有确定的解决方案,特别是与“找不到库”有关。对于有类似问题的人(尝试在Heroku中部署AngularJS),我建议您先阅读以下类似的功能教程: