嘿嘿,
我很難部署這個 react/express 應用程式。構建程序掛起,直到超時。我已經對此進行了大量研究,嘗試了我發現的一切。在倒數第二行有一條“pre-receive hook denied”訊息,這讓我相信這是因為我的堆疊丟失了一些東西。我不熟悉自己使用接近完整的堆疊。我正在使用 node、react、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 是,并且一直在我的 .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"
}
}
Edit: here is a list of the majority of things I've tried. I'm sure I'll miss a couple. Note: this runs fine locally.
Tried both heroku development and production modes.
Set --max-old-space-size=1024, and larger sizes x1024
Set DISABLE_COLLECTSTATIC to 1
Updated: heroku, npm, node, babel, webpack
Set specifically compatible version dependencies for everything I could find information on.
Set watchOptions to "ignore: /node_modules/" in webpack.config.js
Searched for memory leaks, and found none.
Tried every potential solution here.
I know I could just drop my current code in a sandbox and get the gold star from FCC, but I'm doing this because I want to learn everything I can.
uj5u.com熱心網友回復:
請在 gitignore 檔案中添加 node_modules/。
uj5u.com熱心網友回復:
我解決了!!!NODE_CONFIG_PRODUCTION:真,NODE_ENV:生產,NPM_CONFIG_PRODUCTION:假,NODE_MODULES_CACHE:假。
看起來我的配置設定正在安裝依賴項,然后立即修剪它們。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/417530.html
標籤:
