Heyo,
I'm having a difficult time getting this react/express app to deploy. The build process hangs until it times out. I've done tons of research on this, tried everything I have found. There's a "pre-receive hook declined" message on the second to the last line which led me to believe it was something regarding my stack missing something. I am new to using close to the full stack on my own. I'm using 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: > [email protected] 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]
Some solutions seem... wrong? For instance deleting the package-lock.json file seems a poor choice. I've been hacking at this for days at this point. I think my next choice is just to rebuild it methodically so as to isolate what is causing the build to hang.
Edit: node_modules is, and has been in my .gitignore file. Here is my 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.
CodePudding user response:
please add node_modules/ in gitignore file.
CodePudding user response:
I solved it!!! NODE_CONFIG_PRODUCTION: true, NODE_ENV: production, NPM_CONFIG_PRODUCTION: false, NODE_MODULES_CACHE: false.
Looks like my config settings were installing dependencies, and then immediately pruning them.
