我一直在尝试将我的react网站推到heroku上,但是我成功地将其推到github上却不让我这样做。我也更新了我的节点版本,但似乎没有任何作用。这个网站上有关于相同问题的类似问题,我也按照他们的步骤进行,但似乎没有任何作用
sh: 1: ng: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! portfolio@1.0.0 heroku-postbuild: `ng build --prod`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the portfolio@1.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.XmdM7/_logs/2020-02-21T00_18_42_925Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
here's my package.json file
{
"name": "portfolio",
"version": "1.0.0",
"engines": {
"node": "12.16.1",
"npm": "6.13.4"
},
"description": "A clean, beautiful and responsive portfolio template for Developers!",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --config webpack.dev.js --open",
"build": "webpack --config webpack.prod.js",
"heroku-postbuild": "ng build --prod"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mkhawark/portfolio.git"
},
"keywords": [],
"author": "Mohammad Khawar",
"license": "ISC",
"bugs": {
"url": "https://github.com/mkhawark/portfolio/issues"
},
"homepage": "https://github.com/mkhawark/portfolio#readme",
"devDependencies": {
"clean-webpack-plugin": "^3.0.0",
"css-loader": "^3.4.1",
"file-loader": "^5.0.2",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.9.0",
"node-sass": "^4.13.0",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"sass-loader": "^8.0.0",
"style-loader": "^1.1.2",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.10.1",
"webpack-merge": "^4.2.2"
},
"dependencies": {
"bootstrap": "^4.4.1",
"jquery": "^3.4.1",
"popper.js": "^1.16.0",
"tilt.js": "^1.2.1"
}
}
答案 0 :(得分:0)
您已阅读以下内容:https://devcenter.heroku.com/articles/getting-started-with-nodejs
看起来您的启动脚本只是在启动开发服务器,但是使用heroku则必须提供实际的构建文件。
您必须构建项目,然后使用简单的服务器静态提供build文件夹。这是我的一个项目中的示例设置,请注意npm start会启动快速服务器index.js:https://github.com/mattberg88/genome-project/tree/heroku
答案 1 :(得分:0)
您可以通过在node_modules
页面上添加.gitignore
来解决此问题。您可以检查此链接以获取更多信息:Fail to deploy node.js application to heroku
让我知道这是否适合您:)