i am trying to push a react app to a heroku server. I have successfully pushed some react apps before but now its not working... here is the error message i get, when i run this code: git push heroku main
a lot of people are saying that the main branch master or main is protected and that i need to change it but i have no idea where i can do that and it doesnt really create a repository in my github either.
Total 47 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
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): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 16.x...
remote: Downloading and installing node 16.15.1...
remote: Using default npm version: 8.11.0
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote: npm ERR! code EUSAGE
remote: npm ERR!
remote: npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
remote: npm ERR!
remote: npm ERR! Invalid: lock file's [email protected] does not satisfy [email protected]
remote: npm ERR! Missing: [email protected] from lock file
remote: npm ERR! Invalid: lock file's [email protected] does not satisfy [email protected]
remote: npm ERR!
remote: npm ERR! Clean install a project
remote: npm ERR!
remote: npm ERR! Usage:
remote: npm ERR! npm ci
remote: npm ERR!
remote: npm ERR! Options:
remote: npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
remote: npm ERR! [--script-shell <script-shell>]
remote: npm ERR!
remote: npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
remote: npm ERR!
remote: npm ERR! Run "npm help ci" for more info
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.qPgvy/_logs/2022-06-15T14_34_26_231Z-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: 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 test-this-deploy123.
remote:
To https://git.heroku.com/test-this-deploy123.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/test-this-deploy123.git'```
i looked everywhere but nothing has worked for me...
Can anybody please tell me what to do about this?!!?
CodePudding user response:
I added this to my package.json and ran npm install and it pushed to heroku successfully
"engines": {
"node": "16.13.2",
"npm": "8.1.2"
}
CodePudding user response:
Not sure my "answer" is pertinent to your original question, but in my case, I was getting this error during the "npm ci" operation (which is similar to the error in your original question):
53 verbose stack Error: 53 verbose stack `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing. 53 verbose stack 53 verbose stack Invalid: lock file's [email protected] does not satisfy [email protected] 53 verbose stack Missing: [email protected] from lock file 53 verbose stack
I re-ran the "npm install" operation with "silly" loglevel and saw that multiple versions of type-fest were installed as dependencies:
6817 silly audit 'type-fest': [ '0.21.3', '0.8.1', '0.6.0', '0.3.1', '0.20.2' ],
However, version 0.13.1 was NOT installed. This version is listed as a peer dependency of the "React Refresh Webpack Plugin" (@pmmmwh/react-refresh-webpack-plugin). In my case, I solved this problem by explicitly adding
"type-fest": "^0.13.1"as a dependency of my package. Maybe not the best way to solve it, but I've spent too much time trying to get this straightened out already.