I'm trying to create an app on Heroku using git push heroku --force (I'm having trouble integrating remote changes) and keep running into issues while installing dependencies.
Any help is appreciated!
This is the build log:
Enumerating objects: 859, done.
Counting objects: 100% (859/859), done.
Delta compression using up to 4 threads
Compressing objects: 100% (349/349), done.
Writing objects: 100% (859/859), 1.35 MiB | 652.00 KiB/s, done.
Total 859 (delta 479), reused 832 (delta 463), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-22 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 17.9.0
remote: engines.npm (package.json): 8.5.5
remote:
remote: Resolving node version 17.9.0...
remote: Downloading and installing node 17.9.0...
remote: npm 8.5.5 already installed with node
remote:
remote: -----> Restoring cache
remote: Cached directories were not restored due to a change in version of node, npm, yarn or stack
remote: Module installation may take longer for this build
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json)
remote:
remote: > it-project-gekko#1.0.0 install
remote: > cd client && npm install && cd ../server && npm install
remote:
remote: npm ERR! code ERESOLVE
remote: npm ERR! ERESOLVE unable to resolve dependency tree
remote: npm ERR!
remote: npm ERR! While resolving: client#0.1.0
remote: npm ERR! Found: react#18.2.0
remote: npm ERR! node_modules/react
remote: npm ERR! react#"^18.2.0" from the root project
remote: npm ERR!
remote: npm ERR! Could not resolve dependency:
remote: npm ERR! peer react#"^17.0.1" from react-card-flip#1.1.5
remote: npm ERR! node_modules/react-card-flip
remote: npm ERR! react-card-flip#"^1.1.5" from the root project
remote: npm ERR!
remote: npm ERR! Fix the upstream dependency conflict, or retry
remote: npm ERR! this command with --force, or --legacy-peer-deps
remote: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
remote: npm ERR!
remote: npm ERR! See /tmp/npmcache.4IXqU/eresolve-report.txt for a full report.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.4IXqU/_logs/2022-09-24T14_19_38_390Z-debug-0.log
remote: npm ERR! code 1
remote: npm ERR! path /tmp/build_d873d808
remote: npm ERR! command failed
remote: npm ERR! command sh -c cd client && npm install && cd ../server && npm install
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.4IXqU/_logs/2022-09-24T14_19_22_510Z-debug-0.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: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
This is my package.json:
{
"name": "it-project-gekko",
"version": "1.0.0",
"description": "To run locally (tobe updated):",
"main": "server/app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
"start:prod": "cd server && npm run start",
"start:dev": "concurrently \"npm run server\" \"npm run client\" -k",
"client": "cd client && npm run start",
"server": "cd server && npm run dev",
"install": "cd client && npm install && cd ../server && npm install",
"build": "cd client && npm run build"
},
"engines": {
"node": "17.9.0",
"npm": "8.5.5"
},
"repository": {
"type": "git",
"url": "git+https://github.com/lequangtri20/it-project-gekko.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/lequangtri20/it-project-gekko/issues"
},
"homepage": "https://github.com/lequangtri20/it-project-gekko#readme",
"dependencies": {
"axios": "^0.27.2",
"concurrently": "^7.3.0",
"if-env": "^1.0.4",
"styled-components": "^5.3.5"
},
"devDependencies": {
"eslint": "^8.22.0",
"eslint-plugin-react": "^7.30.1"
}
}
Looking at answers to similar posts, I've added the my local node and npm versions.
"engines": {
"node": "17.9.0",
"npm": "8.5.5"
},
However, it didn't solve the problem.
I'm not sure if this would resolve it, but try typing into the terminal: npm install --force
Related
I am following a Udemy course and the github repo is located here: https://github.com/StephenGrider/FullstackReactCode. The error occurs when I try to deploy the application to git and push to Heroku. When I follow these steps Heroku is supposed to automatically install all of the project's server-side dependencies which is caused by a 'heroku-postbuild' script in the server-side-folder JSON package. After Heroku runs all of the server's dependencies, it is supposed to automatically run a 'heroku-postbuild' script that instructs Heroku to (1) install all of the client-side dependencies in the client-side-folder JSON package and then (2) run the command 'npm run build' from within the client-folder directory. After these steps Heroku is supposed to try to start the application but I get the error below. FYI--I followed the directions within the error message but they didn't work. I've also included links to suggested solutions but they don't match my project's package.json structures so the solutions aren't helpful. I've also tried to install eslint as a dependency in both JSON packages but that hasn't worked either.
Possible solutions:
Why is 'type: module' in package.json file?
https://github.com/eslint/eslint/issues/14137
ESlint - Error: Must use import to load ES Module
This is my error:
$ git push heroku master
Enumerating objects: 74, done.
Counting objects: 100% (74/74), done.
Delta compression using up to 12 threads
Compressing objects: 100% (59/59), done.
Writing objects: 100% (63/63), 170.95 KiB | 5.18 MiB/s, done.
Total 63 (delta 17), 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_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 12.16.3
remote: engines.npm (package.json): 6.14.4
remote:
remote: Resolving node version 12.16.3...
remote: Downloading and installing node 12.16.3...
remote: npm 6.14.4 already installed with node
remote:
remote: -----> Restoring cache
remote: - node_modules
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote:
remote: > nodemon#2.0.15 postinstall /tmp/build_fc9f4df1/node_modules/nodemon
remote: > node bin/postinstall || exit 0
remote:
remote: Love nodemon? You can now support the project via the open collective:
remote: > https://opencollective.com/nodemon/donate
remote:
remote: added 295 packages in 4.112s
remote:
remote: -----> Build
remote: Running heroku-postbuild
remote:
remote: > server#1.0.0 heroku-postbuild /tmp/build_fc9f4df1
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote:
remote:
remote: > core-js#3.21.1 postinstall /tmp/build_fc9f4df1/client/node_modules/core-js
remote: > node -e "try{require('./postinstall')}catch(e){}"
remote:
remote:
remote: > core-js-pure#3.21.1 postinstall /tmp/build_fc9f4df1/client/node_modules/core-js-pure
remote: > node -e "try{require('./postinstall')}catch(e){}"
remote:
remote: added 1434 packages from 699 contributors and audited 1436 packages in 19.485s
remote:
remote: 169 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 4 moderate severity vulnerabilities
remote: run `npm audit fix` to fix them, or `npm audit` for details
remote:
remote: > client#0.1.0 build /tmp/build_fc9f4df1/client
remote: > react-scripts build
remote:
remote: Creating an optimized production build...
remote: Failed to compile.
remote:
remote: Must use import to load ES Module: /tmp/build_fc9f4df1/client/node_modules/#eslint/eslintrc/universal.js
remote: require() of ES modules is not supported.
remote: require() of /tmp/build_fc9f4df1/client/node_modules/#eslint/eslintrc/universal.js from
/tmp/build_fc9f4df1/client/node_modules/eslint/lib/linter/linter.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
remote: Instead rename universal.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /tmp/build_fc9f4df1/client/node_modules/#eslint/eslintrc/package.json.
remote:
remote:
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! client#0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the client#0.1.0 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.fuU8Z/_logs/2022-03-18T18_29_34_363Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! server#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the server#1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.fuU8Z/_logs/2022-03-18T18_29_34_382Z-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: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to stormy-journey-31783.
remote:
To https://git.heroku.com/stormy-journey-31783.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/stormy-journey-31783.git'
This is my Heroku Build Log:
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 12.16.3
engines.npm (package.json): 6.14.4
Resolving node version 12.16.3...
Downloading and installing node 12.16.3...
npm 6.14.4 already installed with node
-----> Restoring cache
- node_modules
-----> Installing dependencies
Installing node modules
> nodemon#2.0.15 postinstall /tmp/build_40a7066f/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
added 228 packages in 3.89s
-----> Build
Running heroku-postbuild
> server#1.0.0 heroku-postbuild /tmp/build_40a7066f
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
> core-js#3.21.1 postinstall /tmp/build_40a7066f/client/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js-pure#3.21.1 postinstall /tmp/build_40a7066f/client/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
added 1435 packages from 699 contributors and audited 1437 packages in 20.981s
169 packages are looking for funding
run `npm fund` for details
found 4 moderate severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
> client#0.1.0 build /tmp/build_40a7066f/client
> react-scripts build
Creating an optimized production build...
Failed to compile.
Must use import to load ES Module: /tmp/build_40a7066f/client/node_modules/#eslint/eslintrc/universal.js
require() of ES modules is not supported.
require() of /tmp/build_40a7066f/client/node_modules/#eslint/eslintrc/universal.js from /tmp/build_40a7066f/client/node_modules/eslint/lib/linter/linter.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename universal.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /tmp/build_40a7066f/client/node_modules/#eslint/eslintrc/package.json.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client#0.1.0 build 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.PAGiQ/_logs/2022-03-15T22_15_39_679Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the server#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.PAGiQ/_logs/2022-03-15T22_15_39_694Z-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
This is my package.json file in the server-side folder directory:
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": "12.16.3",
"npm": "6.14.4"
},
"scripts": {
"start": "node index",
"server": "nodemon index",
"client": "npm run start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.2",
"concurrently": "^7.0.0",
"cookie-session": "^2.0.0",
"eslint": "^8.11.0",
"express": "^4.17.1",
"mongoose": "^6.2.4",
"nodemon": "^2.0.15",
"passport": "^0.5.2",
"passport-google-oauth20": "^2.0.0",
"stripe": "^8.209.0"
}
}
This is my package.json file in the client-side folder directory:
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.16.2",
"#testing-library/react": "^12.1.4",
"#testing-library/user-event": "^13.5.0",
"axios": "^0.26.1",
"eslint": "^8.11.0",
"http-proxy-middleware": "^2.0.3",
"materialize-css": "^1.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.6",
"react-router-dom": "^5.3.0",
"react-scripts": "5.0.0",
"react-stripe-checkout": "^2.6.3",
"redux": "^4.1.2",
"redux-thunk": "^2.4.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I'm trying to use the Heroku CLI to get a MERN app online. The app works perfectly locally but when I try to use git to push the app onto Heroku I get the following error message:
remote: Running heroku-postbuild
remote:
remote: > exercise-logger#1.0.0 heroku-postbuild /tmp/build_431a136c
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix exercise-logger && npm run build --prefix exercise-logger
remote:
remote: up to date in 0.22s
remote: found 0 vulnerabilities
remote:
remote: npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/build_431a136c/exercise-logger/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_431a136c/exercise-logger/package.json'
remote: npm ERR! enoent This is related to npm not being able to find a file.
remote: npm ERR! enoent
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.yesMz/_logs/2021-05-30T17_32_30_947Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 254
remote: npm ERR! exercise-logger#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix exercise-logger && npm run build --prefix exercise-logger`
remote: npm ERR! Exit status 254
remote: npm ERR!
remote: npm ERR! Failed at the exercise-logger#1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.yesMz/_logs/2021-05-30T17_32_30_973Z-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_modules checked into source control
remote: https://devcenter.heroku.com/articles/node-best-practices#only-git-the-important-bits
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: !
The thrust of it seems to be that it can't find the root package.json file, even though it's definitely there. In fact, here it is:
"name": "exercise-logger",
"version": "1.0.0",
"description": "",
"main": "server.js",
"dependencies": {
"axios": "^0.21.1",
"bcrypt": "^5.0.1",
"concurrently": "^6.0.2",
"config": "^3.3.6",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-validator": "^6.10.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.12.3"
},
"devDependencies": {},
"scripts": {
"start": "node server.js",
"build": "cd client && npm run build",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"clientinstall": "npm install --prefix client",
"dev": "concurrently \"npm run start\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"engines": {
"node": "14.x",
"npm": "6.x"
},
"author": "",
"license": "ISC"
}
I have tried what seems to be a common fix which is manually deleting the .git folder in the directory for the React app but doesn't seem to have fixed it.
The whole code is on Github here.
Can anyone help? I've been working on this project for quite a while so it's really frustrating to fall at the final hurdle like this. I've not really done anything like this before so not really sure where to start troubleshooting!
Thanks
I'm really stuck and would really appreciate some help. This question was asked previously here Error while pushing to Heroku: Cannot find module 'node-linux-x64/package.json' however, despite trying all the suggestions I was still unable to resolve this problem.
Just like the individual before who posted the problem initially, I am trying to push a full stack Javascript app to Heroku.
I've re-installed all my dependencies and even downgraded my node and npm.
This issue is especially confusing as I am a Windows user, so to be receiving an error about a module regarding linux feels quite strange.
Please help.
C:\Users\Greg\Desktop\GregBots\reactbot> git push heroku master
Enumerating objects: 41, done.
Counting objects: 100% (41/41), done.
Delta compression using up to 8 threads
Compressing objects: 100% (28/28), done.
Writing objects: 100% (28/28), 19.45 KiB | 1.95 MiB/s, done.
Total 28 (delta 15), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 13.6.0
remote: engines.npm (package.json): 6.13.4
remote:
remote: Resolving node version 13.6.0...
remote: Downloading and installing node 13.6.0...
remote: npm 6.13.4 already installed with node
remote:
remote: -----> Restoring cache
remote: Cached directories were not restored due to a change in version of node, npm, yarn or stack
remote: Module installation may take longer for this build
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote:
remote: > node#13.8.0 preinstall /tmp/build_5798122e415d759253929a4b5b0a6c16/node_modules/node
remote: > node installArchSpecificPackage
remote:
remote: npm ERR! code ETARGET
remote: npm ERR! notarget No matching version found for node-linux-x64#13.8.0.
remote: npm ERR! notarget In most cases you or one of your dependencies are requesting
remote: npm ERR! notarget a package version that doesn't exist.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.3VsTs/_logs/2020-02-26T01_02_25_357Z-debug.log
remote: internal/modules/cjs/loader.js:976
remote: throw err;
remote: ^
remote:
remote: Error: Cannot find module 'node-linux-x64/package.json'
remote: Require stack:
remote: - /tmp/build_5798122e415d759253929a4b5b0a6c16/node_modules/node/installArchSpecificPackage.js
remote: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:973:15)
remote: at Function.resolve (internal/modules/cjs/helpers.js:78:19)
remote: at ChildProcess.<anonymous> (/tmp/build_5798122e415d759253929a4b5b0a6c16/node_modules/node-bin-setup/index.js:18:27)
remote: at ChildProcess.emit (events.js:321:20)
remote: at maybeClose (internal/child_process.js:1028:16)
remote: at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {
remote: code: 'MODULE_NOT_FOUND',
remote: requireStack: [
remote: '/tmp/build_5798122e415d759253929a4b5b0a6c16/node_modules/node/installArchSpecificPackage.js'
remote: ]
remote: }
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! node#13.8.0 preinstall: `node installArchSpecificPackage`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the node#13.8.0 preinstall script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.3VsTs/_logs/2020-02-26T01_02_26_775Z-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: - A module may be missing from 'dependencies' in package.json
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to infinite-sea-94371.
remote:
To https://git.heroku.com/infinite-sea-94371.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/infinite-sea-94371.git'
PS C:\Users\Greg\Desktop\GregBots\reactbot>
Thanks a bunch for your suggestions Mazen. I've went through your advice, but can't deploy to Heroku still. I've now attached my package.json which I am pushing as well to Heroku as Heroku installs the dependencies that are needed as per the package.
{
"name": "reactbot",
"version": "1.0.0",
"description": "React bot",
"main": "index.js",
"engines": {
"node": "13.6.0",
"npm": "6.13.4"
},
"scripts": {
"start": "node index.js",
"backend": "nodemon index.js",
"frontend": "npm run start --prefix client",
"dev": "concurrently \"npm run backend\" \"npm run frontend\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"author": "",
"license": "ISC",
"dependencies": {
"actions-on-google": "^2.12.0",
"body-parser": "^1.19.0",
"dialogflow": "^1.2.0",
"dialogflow-fulfillment": "^0.6.1",
"express": "^4.17.1",
"mongoose": "^5.9.2"
},
"devDependencies": {
"concurrently": "^5.1.0",
"nodemon": "^2.0.2"
}
}
This error might be caused by multiple things:
According to your error, the npm package node-linux-x64 is set to the wrong version that doesn't exist. Remove node-linux-x64 as Heroku installs the most updated version of Node.js for their system or set it to an existing version.
Did you push your package.json file with your code?
You have pushed your node_module to Heroku which has certain versions of some packages that can only work on your distribution/OS.
You might have installed an npm package globally and forgot to include it to your packages.json file.
I am new to Heroku and am facing problems pushing my code to Heroku. I have a React/Node JS project. My folder structure is as follows:
I had my package.json file initially under backend folder but due to buildpack error I moved it to the root folder.
When I try pushing code to Heroku I get the following error:
\ProductInventoryApp> git push heroku HEAD:master
Enumerating objects: 110, done.
Counting objects: 100% (110/110), done.
Delta compression using up to 8 threads
Compressing objects: 100% (107/107), done.
Writing objects: 100% (110/110), 425.50 KiB | 2.73 MiB/s, done.
Total 110 (delta 38), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 12.x...
remote: Downloading and installing node 12.14.1...
remote: Using default npm version: 6.13.4
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote: added 161 packages from 100 contributors and audited 304 packages in 7.815s
remote:
remote: 2 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 0 vulnerabilities
remote:
remote:
remote: -----> Build
remote: Running heroku-postbuild
remote:
remote: > ProductInventoryApp#1.0.0 heroku-postbuild /tmp/build_e7c760dc5d523bf5e1c2d0dc2b5b85cf
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
remote:
remote: up to date in 0.524s
remote: found 0 vulnerabilities
remote:
remote: npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/build_e7c760dc5d523bf5e1c2d0dc2b5b85cf/client/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/build_e7c760dc5d523bf5e1c2d0dc2b5b85cf/client/package.json'
remote: npm ERR! enoent This is related to npm not being able to find a file.
remote: npm ERR! enoent
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.HV3Sb/_logs/2020-01-12T03_23_13_871Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 254
remote: npm ERR! ProductInventoryApp#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
remote: npm ERR! Exit status 254
remote: npm ERR!
remote: npm ERR! Failed at the ProductInventoryApp#1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.HV3Sb/_logs/2020-01-12T03_23_13_887Z-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:
remote: ! Push rejected to product-inventory-app.
remote:
To https://git.heroku.com/product-inventory-app.git
**! [remote rejected] HEAD -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/product-inventory-app.git'**
I am not sure what’s causing this. My package.json file is as follows:
{
"name": "ProductInventoryApp",
"version": "1.0.0",
"description": "",
"main": "backend/app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js",
"client-install": "npm install --prefix client",
"server": "nodemon app.js",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-validator": "^6.3.0",
"mongodb": "^3.4.0",
"mongoose": "^5.8.0",
"uuid": "^3.3.3"
},
"devDependencies": {
"concurrently": "^4.0.1"
}
}
This is being caused by an issue with the heroku-postbuild script that you've defined. Remove it from the package.json file and redeploy to Heroku to resolve the issue.
try this.. it will help you out
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix frontend && npm run build --prefix frontend"
basically, --prefix represents the path where react's package.json will exist... so, your react's package.json might be existed in frontend folder...
I've had the same problem until I've realised that my client/package.json was part of my .gitignore.
If you are using Visual Studio, it does automatically add your package to it when creating gitignore.
I was facing the same error of Heroku: “no such file or directory” but for a different problem.
In my case, I'm using docker and a docker-compose.yml with volumes to share volumes.
Heroku need instead of this file a heroku.yml which takes fewer options.
So it is needed to bring some changes to the Dockerfile (or make a copy specially for Heroku)
My docker-compose.yml file :
services:
web:
volumes:
- .:/usr/src/app
For my heroku.yml configuration, I set :
build:
docker:
web: Dockerfile.web
with a Dockerfile.web same as the original Dockerfile with the following difference :
...
ADD . /usr/src/app
...
I build an app to practice react with a nodejs backend. It work fine on localhost. But I needed to learn how to deploy it on Heroku. I followed Stephen Grider's Udemy course and tried to hosted it on Heroku.
But my build fails. I checked many times and ran npm install even. But I can't get it working.
This is my package.json in server
{
"name": "react-movies",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"server": "nodemon index.js",
"client": "npm run start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm insall --prefix client && npm run build --prefix client"
},
"engines": {
"node": "8.9.4",
"npm": "5.7.1"
},
"author": "pankaja92",
"license": "ISC",
"dependencies": {
"concurrently": "^3.5.1",
"moviedb-promise": "^1.2.1",
"express": "^4.16.3",
"nodemon": "^1.17.2"
}
}
And this is the build error I'm getting.
Counting objects: 25, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (25/25), 5.50 KiB | 2.75 MiB/s, done.
Total 25 (delta 15), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 8.9.4
remote: engines.npm (package.json): 5.7.1
remote:
remote: Resolving node version 8.9.4...
remote: Downloading and installing node 8.9.4...
remote: Bootstrapping npm 5.7.1 (replacing 5.6.0)...
remote: npm 5.7.1 installed
remote:
remote: -----> Restoring cache
remote: Skipping cache restore (new-signature)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json + package-lock)
remote:
remote: > nodemon#1.17.2 postinstall /tmp/build_ac7e6ff23b1b667ae4e3970742a18cc1/node_modules/nodemon
remote: > node -e "console.log('u001b[32mLove nodemon? You can now support the project via the open collective:u001b[22mu001b[39mn > u001b[96mu001b[1mhttps://opencollective.com/nodemon/donateu001b[0mn')" || exit 0
remote:
remote: Love nodemon? You can now support the project via the open collective:
remote: > https://opencollective.com/nodemon/donate
remote:
remote: added 319 packages from 194 contributors in 7.977s
remote: Running heroku-postbuild
remote:
remote: > react-movies#1.0.0 heroku-postbuild /tmp/build_ac7e6ff23b1b667ae4e3970742a18cc1
remote: > NPM_CONFIG_PRODUCTION=false npm insall --prefix client && npm run build --prefix client
remote:
remote:
remote: Usage: npm <command>
remote:
remote: where <command> is one of:
remote: access, adduser, bin, bugs, c, cache, ci, completion,
remote: config, ddp, dedupe, deprecate, dist-tag, docs, doctor,
remote: edit, explore, get, help, help-search, i, init, install,
remote: install-test, it, link, list, ln, login, logout, ls,
remote: outdated, owner, pack, ping, prefix, profile, prune,
remote: publish, rb, rebuild, repo, restart, root, run, run-script,
remote: s, se, search, set, shrinkwrap, star, stars, start, stop, t,
remote: team, test, token, tst, un, uninstall, unpublish, unstar,
remote: up, update, v, version, view, whoami
remote:
remote: npm <command> -h quick help on <command>
remote: npm -l display full usage info
remote: npm help <term> search for help on <term>
remote: npm help npm involved overview
remote:
remote: Specify configs in the ini-formatted file:
remote: /app/.npmrc
remote: or on the command line via: npm <command> --key value
remote: Config info can be viewed via: npm help config
remote:
remote: npm#5.7.1 /tmp/build_ac7e6ff23b1b667ae4e3970742a18cc1/.heroku/node/lib/node_modules/npm
remote:
remote: Did you mean one of these?
remote: install
remote: uninstall
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! react-movies#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm insall --prefix client && npm run build --prefix client`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the react-movies#1.0.0 heroku-postbuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.31Mmf/_logs/2018-03-22T20_32_50_639Z-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: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to findthemovie.
remote:
What have I done wrong ? Why's my build is failing ?
Can anyone help me with this ?
Would put this as a comment but can't yet, check a spelling error in config file
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm insall --prefix client && npm run build --prefix client"
Ain't that supposed to be install?
npm install
> NPM_CONFIG_PRODUCTION=false npm insall --prefix client && npm run build --prefix client
should be
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
I believe there is a typo in your code.
It should be install instead of insall :
NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
add this code in server.js file
if (process.env.NODE_ENV === "production") {
app.use(express.static(path.join(__dirname, "client/build")));
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
});
}