Heroku 部署 - "推送被拒绝,无法编译 Node.js 应用程序"



尝试将 Laravel+vue 应用程序部署到 heroku,但在使用 git push heroku master 时,我得到以下跟踪(仅显示整个跟踪的一部分,但我认为这是问题的部分 - 如果没有让我知道(:

remote:        npm ERR! code EINTEGRITY
remote:        npm ERR! sha512- 
Prh/h9CB1jBCBIjSLD6kvIWhMV5S25Bwv7yK0fYJSOTIyg1CmU9OqNdRVCkdWyQY1Hkvm+1YdXJzh3xYupq1KA== 
integrity checksum failed when using sha512: wanted sha512- 
Prh/h9CB1jBCBIjSLD6kvIWhMV5S25Bwv7yK0fYJSOTIyg1CmU9OqNdRVCkdWyQY1Hkvm+1YdXJzh3xYupq1KA== but 
got sha512- 
QItiGZBy5TstGy+q8mjQTMGRlDDOARXLxH+sgVm1n/LYeo0zFcQlcCh8m4zi8QxctrxB9Kue/lStc/RD5iLadQ==. 
(896052 bytes)
remote:        
remote:        npm ERR! A complete log of this run can be found in:
remote:        npm ERR!     /tmp/npmcache.8lpmC/_logs/2020-06-05T11_28_24_085Z-debug.log
remote: 
remote: -----> Build failed
remote:        
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:        
remote:        Some possible problems:
remote:        
remote:        - Node version not specified in package.json
remote:          https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js- 
version
remote:        
remote:        Love,
remote:        Heroku
remote:        
remote:  !     Push rejected, failed to compile Node.js app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 

这是我的包.json

{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"postinstall": "npm run prod",
"heroku-postbuild": "npm run prod"
},
"devDependencies": {
"axios": "^0.19",
"bootstrap": "^4.0.0",
"cross-env": "^5.1",
"jquery": "^3.5.1",
"laravel-mix": "^5.0.1",
"lodash": "^4.17.13",
"popper.js": "^1.12",
"resolve-url-loader": "^2.3.1",
"sass": "^1.20.1",
"sass-loader": "^8.0.0",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"@fullcalendar/core": "^4.4.0",
"@fullcalendar/daygrid": "^4.4.0",
"@fullcalendar/interaction": "^4.4.0",
"@fullcalendar/vue": "^4.4.0",
"@types/dhtmlxgantt": "^6.0.2",
"admin-lte": "^3.0.2",
"babel-runtime": "^6.26.0",
"bootstrap-vue": "^2.15.0",
"dhtmlx-gantt": "^6.3.7",
"laravel-echo": "^1.7.0",
"laravel-vue-pagination": "^2.3.1",
"mdbvue": "^6.7.0",
"moment": "^2.24.0",
"pusher-js": "^5.1.1",
"sweetalert2": "^9.8.2",
"vform": "^1.0.1",
"vue-full-calendar": "^2.7.0",
"vue-print-nb": "^1.5.0",
"vue-progressbar": "^0.7.5",
"vue-router": "^3.1.6",
"vuex": "^3.1.3"
},
"engines": {
"node": "12.x"
}
}

里面有一堆错误,我不知道为什么会这样。 但是经过多次研究,我尝试了很多方法,但我没有找到解决方案。所以任何帮助的家伙,我从 2 天以来就被困在这里

在指定节点版本的地方,还要指定节点版本。 看看它是否有效。它对我有用。

"engines": { "node": "12.x", "npm": "your version" }

指定对象块engines帮助我使用 Laravel 应用程序和 Rails 应用程序

package.json (append(

"engines": {
"node": "12.x"
}

有点奇怪,但是当它起作用时,它就会起作用。

我还添加了一个@dependabot变基,以便使用 heroku 的预览版本允许我在分支内验证这是阻止应用程序构建的唯一问题。

在终端中检查节点和 npm 的版本:

node -v
npm -v

并在您的 package.json 中更新两者(示例(:

"engines": {
"node": "14.x",
"npm": "7.x"
}

只是放置节点版本对我没有帮助,因为 Heroku 自动尝试构建另一个版本的 npm 并崩溃

在这里阅读更多内容: https://devcenter.heroku.com/articles/deploying-nodejs#specify-the-version-of-node

最新更新