簡體   English   中英

掛在 git 上的 Express 應用程序構建推送到 Heroku

[英]Express app build hanging on git push to Heroku

嘿嘿,

我很難部署這個 react/express 應用程序。 構建過程掛起,直到超時。 我已經對此進行了大量研究,嘗試了我發現的一切。 在倒數第二行有一條“pre-receive hook denied”消息,這讓我相信這是因為我的堆棧丟失了一些東西。 我不熟悉自己使用接近完整的堆棧。 我正在使用節點、反應、babel、webpack。

 Counting objects: 10703, done. Delta compression using up to 8 threads. Compressing objects: 100% (10145/10145), done. Writing objects: 100% (10703/10703), 14.31 MiB | 2.95 MiB/s, done. Total 10703 (delta 2066), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Building on the Heroku-20 stack remote: -----> Using buildpack: heroku/nodejs remote: -----> Node.js app detected remote: remote: -----> Creating runtime environment remote: remote: NPM_CONFIG_PRODUCTION=false remote: NPM_CONFIG_LOGLEVEL=error remote: NODE_OPTIONS=--max-old-space-size=1024 remote: NODE_VERBOSE=false remote: NODE_ENV=development remote: NODE_CONFIG_PRODUCTION=false remote: NODE_MODULES_CACHE=false remote: remote: -----> Installing binaries remote: engines.node (package.json): 16.13.x remote: engines.npm (package.json): ^8.3.1 remote: remote: Resolving node version 16.13.x... remote: Downloading and installing node 16.13.2... remote: Bootstrapping npm ^8.3.1 (replacing 8.1.2)... remote: npm ^8.3.1 installed remote: remote: -----> Restoring cache remote: Caching has been disabled because NODE_MODULES_CACHE=false remote: remote: -----> Installing dependencies remote: Installing node modules remote: remote: added 742 packages, and audited 743 packages in 18s remote: remote: 88 packages are looking for funding remote: run `npm fund` for details remote: remote: found 0 vulnerabilities remote: remote: -----> Build remote: Running heroku-postbuild remote: remote: > react-markdown-previewer@1.0.0 heroku-postbuild remote: > webpack -w remote: remote: assets by path /assets/ 3.7 KiB remote: asset /assets/Github-Mark-32px.png 1.67 KiB [compared for emit] [from: dist/assets/Github-Mark-32px.png] (auxiliary name: main) remote: asset /assets/free-code-camp-brands.svg 1.38 KiB [compared for emit] [from: dist/assets/free-code-camp-brands.svg] (auxiliary name: main) remote: asset /assets/linkedin-brands.svg 660 bytes [compared for emit] [from: dist/assets/linkedin-brands.svg] (auxiliary name: main) remote: asset main.js 1.1 MiB [compared for emit] (name: main) remote: asset index.html 38.2 KiB [emitted] remote: runtime modules 1.98 KiB 6 modules remote: modules by path./node_modules/ 1.03 MiB remote: modules by path./node_modules/style-loader/dist/runtime/*.js 5.75 KiB 6 modules remote: modules by path./node_modules/scheduler/ 26.3 KiB 4 modules remote: modules by path./node_modules/react/ 70.6 KiB 2 modules remote: modules by path./node_modules/react-dom/ 875 KiB 2 modules remote: modules by path./node_modules/css-loader/dist/runtime/*.js 2.33 KiB 2 modules remote: 2 modules remote: modules by path./dist/ 4.62 KiB remote: modules by path./dist/assets/ 220 bytes 3 modules remote: modules by path./dist/styles/*.scss 4.41 KiB remote: ./dist/styles/main.scss 1.22 KiB [built] [code generated] remote: ./node_modules/css-loader/dist/cjs.js../node_modules/sass-loader/dist/cjs.js../dist/styles/main:scss 3.19 KiB [built] [code generated] remote. ./src/index:js 10.8 KiB [built] [code generated] remote. webpack 5:66:0 compiled successfully in 1816 ms remote: -----> Timed out running buildpack Node.js remote: Terminated remote: remote. . Push failed remote. Verifying deploy::. remote: remote: ! Push rejected to [app-name]. remote: To [app-name] ! [remote rejected] main -> main (pre-receive hook declined) error: failed to push some refs to [app-name]

一些解決方案似乎......錯了? 例如刪除 package-lock.json 文件似乎是一個糟糕的選擇。 在這一點上,我已經在這方面進行了幾天的黑客攻擊。 我認為我的下一個選擇只是有條不紊地重建它,以便隔離導致構建掛起的原因。

編輯: node_modules 是,並且一直在 my.gitignore 文件中。 這是我的 package.json

 { "name": "react-markdown-previewer", "version": "1.0.0", "description": "freecodecamp front end libraries project", "main": "main.js", "engines": { "npm": "^8.3.1", "node": "16.13.x" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "node server.js", "sass": "sass --watch dist/styles:dist/styles", "heroku-postbuild": "webpack -w" }, "keywords": [ "freecodecamp", "fcc", "babel", "react", "webpack" ], "author": "Matt", "license": "MIT", "dependencies": { "@babel/core": "^7.16.7", "@babel/preset-env": "^7.16.7", "@babel/preset-react": "^7.16.7", "babel-loader": "^8.2.3", "cli": "^1.0.1", "css-loader": "^6.5.1", "express": "^4.17.2", "file-loader": "^6.2.0", "html-webpack-plugin": "^5.5.0", "img-loader": "^4.0.0", "marked": "^4.0.10", "node-sass": "^7.0.1", "react": "^17.0.2", "react-dom": "^17.0.2", "sass-loader": "^12.4.0", "style-loader": "^3.3.1", "url-loader": "^4.1.1" }, "devDependencies": { "@babel/core": "^7.16.7", "@babel/preset-env": "^7.16.7", "@babel/preset-react": "^7.16.7", "babel-loader": "^8.2.3", "css-loader": "^6.5.1", "file-loader": "^6.2.0", "html-webpack-plugin": "^5.5.0", "img-loader": "^4.0.0", "node-sass": "^7.0.1", "style-loader": "^3.3.1", "url-loader": "^4.1.1", "webpack": "^5.66.0", "webpack-cli": "^4.9.1", "webpack-dev-server": "^4.7.2" } }

編輯:這是我嘗試過的大部分事情的列表。 我敢肯定我會想念一對夫婦。 注意:這在本地運行良好。

嘗試了 heroku 開發和生產模式。
設置 --max-old-space-size=1024,以及更大的尺寸 x1024
將 DISABLE_COLLECTSTATIC 設置為 1
更新:heroku、npm、節點、通天塔、webpack
為我能找到的所有信息設置專門兼容的版本依賴項。
在 webpack.config.js 中將 watchOptions 設置為“忽略:/node_modules/”
搜索 memory 泄漏,沒有找到。
在這里嘗試了所有潛在的解決方案。

我知道我可以將我當前的代碼放在沙箱中並從 FCC 獲得金星,但我這樣做是因為我想學習我能學到的一切。

請在 gitignore 文件中添加 node_modules/。

我解決了:,:NODE_CONFIG_PRODUCTION,真:NODE_ENV,生產:NPM_CONFIG_PRODUCTION。 假,NODE_MODULES_CACHE:假。

看起來我的配置設置正在安裝依賴項,然后立即修剪它們。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM