Trouble deploying to Heroku, module can't resolve - node.js

Been trying all day to deploy this. Nothing is working. Ran through the entire node troubleshooter link, everything checks out. The where it says cant resolve module, My code is running fine on all severs and can't find the tmp folder, anywhere. I've only been coding a month. Sorry if this is stupid, but I'd appreciate some help.
Matt#DESKTOP-QFMSSDA MINGW64 ~/Desktop/momma-ecommerce (main)
$ git push heroku main
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 442 bytes | 442.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0), pack-reused 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_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 16.13.2
remote: engines.npm (package.json): 8.1.2
remote:
remote: Resolving node version 16.13.2...
remote: Downloading and installing node 16.13.2...
remote: npm 8.1.2 already installed with node
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote:
remote: added 252 packages, and audited 253 packages in 9s
remote:
remote: 24 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: > momma-art-sell#1.0.0 heroku-postbuild
remote: > NPM_CONFIG_PRODUCTION=false npm install --prefix frontend && npm run build --
prefix frontend
remote:
remote:
remote: added 1445 packages, and audited 1446 packages in 24s
remote:
remote: 171 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: 7 moderate severity vulnerabilities
remote:
remote: To address issues that do not require attention, run:
remote: npm audit fix
remote:
remote: To address all issues (including breaking changes), run:
remote: npm audit fix --force
remote:
remote: Run `npm audit` for details.
remote:
remote: > frontend#0.1.0 build
remote: > react-scripts build
remote:
remote: Creating an optimized production build...
remote: Failed to compile.
remote:
remote: Module not found: Error: Can't resolve '../components/Message' in
'/tmp/build_4ecd4ad3/frontend/src/screens'
remote:
remote:
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 mjthomasart.
remote:
To https://git.heroku.com/mjthomasart.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/mjthomasart.git'``

Related

Heroku: react-scripts: Permission denied while deploying on Heroku

I am getting this error while deploying mern application on heroku by heroku cli. How to resolve react-scripts: Permission denied ? I tried npm install react-scripts --save but still give me npm errors.
remote: -----> Build
remote: Running heroku-postbuild
remote:
remote: > backend#1.0.0 heroku-postbuild
remote: > cd client && npm install --legacy-peer-deps && npm run build
remote:
remote:
remote: removed 9 packages, and audited 1465 packages in 3s
remote:
remote: 217 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: 6 high severity vulnerabilities
remote:
remote: To address all issues (including breaking changes), run:
remote: npm audit fix --force
remote:
remote: Run `npm audit` for details.
remote:
remote: > react-login#1.0.0 build
remote: > react-scripts build
remote:
remote: /tmp/build-a0701c25.sh: 1: react-scripts: Permission denied
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: Verifying deploy...
remote: ! Push rejected to react-login-system.
remote:
To https://git.heroku.com/react-login-system.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/react-login-system.git'

Could not find a required file index.js, searched in /tmp/build_43da642b/src

I tried to push my recent code to Heroku. Here is what I got in the console:
Enumerating objects: 39, done.
Counting objects: 100% (39/39), done.
Delta compression using up to 8 threads
Compressing objects: 100% (26/26), done.
Writing objects: 100% (32/32), 2.90 KiB | 593.00 KiB/s, done.
Total 32 (delta 12), reused 0 (delta 0), pack-reused 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): 16.14.0
remote: engines.npm (package.json): 8.3.1
remote:
remote: Resolving node version 16.14.0...
remote: Downloading and installing node 16.14.0...
remote: npm 8.3.1 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
remote:
remote: added 1403 packages, and audited 1404 packages in 28s
remote:
remote: 175 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: 8 vulnerabilities (6 moderate, 2 high)
remote:
remote: To address issues that do not require attention, run:
remote: npm audit fix
remote:
remote: To address all issues (including breaking changes), run:
remote: npm audit fix --force
remote:
remote: Run `npm audit` for details.
remote:
remote: -----> Build
remote: Running build
remote:
remote: > chatapp-project#0.1.0 build
remote: > react-scripts build
remote:
remote: Could not find a required file.
remote: Name: index.js
remote: Searched in: /tmp/build_1ff4f4ff/src
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 chatapp-project-kasper.
remote:
To https://git.heroku.com/chatapp-project-kasper.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/chatapp-project-kasper.git'
It seems it is searching for a file somewhere. This is my folder structure:
https://i.stack.imgur.com/fISfz.png
I am unsure where this file is, or how I can change where heroku searches for the file. Also, in my Procfile I have this:
web: node src/App.js
Any help would be greatly appreciated.

Error: failed to push some refs in heroku

I was following a course online on how to deploy in Heroku. I made a Git repository and uploaded and committed all the files there. Then I typed these commands:
heroku create
heroku git:remote -a name_provided_by_heroku
git push heroku main
After command 3 I faced this error in cmd:
Enumerating objects: 4357, done.
Counting objects: 100% (4357/4357), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4125/4125), done.
Writing objects: 100% (4357/4357), 3.64 MiB | 297.00 KiB/s, done.
Total 4357 (delta 935), reused 3 (delta 0), pack-reused 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.20.0...
remote: Using default npm version: 6.14.8
remote:
remote: -----> Installing dependencies
remote: Prebuild detected (node_modules already exists)
remote: Rebuilding any native modules
remote:
remote: > bcrypt#5.0.0 install /tmp/build_88514da7/node_modules/bcrypt
remote: > node-pre-gyp install --fallback-to-build
remote:
remote: sh: 1: node-pre-gyp: Permission denied
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! bcrypt#5.0.0 install: `node-pre-gyp install --fallback-to-build`
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the bcrypt#5.0.0 install 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.MO7JR/_logs/2020-12-15T17_16_14_007Z-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: - 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 safe-dawn-68695.
remote:
To https://git.heroku.com/safe-dawn-68695.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/safe-dawn-68695.git'
I am new to Heroku, so I am not able to get what the error is saying. Also tried using git push heroku HEAD:master but faced the same error.
How do I solve this?
Refering this article: node-pre-gyp: Permission denied in heroku push
Remove node_modules folder in your root folder rm -rf node_modules beacuse heroku will install all your dependencies, I hope this will work
So remove your node modules folder and do 1 2 3 again

Failed to push some refs in Heroku

`I tried to push my web application to Heroku but it gave me this error. I searched for similar problems but it didn't help me. I did this before and it worked but when I tried to do it again it failed and I don't know why.
How can I resolve this error?
PS D:\react application> git push heroku master
Enumerating objects: 125, done.
Counting objects: 100% (125/125), done.
Delta compression using up to 4 threads
Compressing objects: 100% (116/116), done.
Writing objects: 100% (125/125), 2.56 MiB | 31.00 KiB/s, done.
Total 125 (delta 29), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Build failed
remote: ! Two different lockfiles found: package-lock.json and yarn.lock
remote:
remote: Both npm and yarn have created lockfiles for this application,
remote: but only one can be used to install dependencies. Installing
remote: dependencies using the wrong package manager can result in missing
remote: packages or subtle bugs in production.
remote:
remote: - To use npm to install your application's dependencies please delete
remote: the yarn.lock file.
remote:
remote: $ git rm yarn.lock
remote:
remote: - To use yarn to install your application's dependences please delete
remote: the package-lock.json file.
remote:
remote: $ git rm package-lock.json
remote:
remote: https://kb.heroku.com/why-is-my-node-js-build-failing-because-of-conflicting-lock-files
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to heroku-react-app-3.
remote:
To https://git.heroku.com/heroku-react-app-3.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/heroku-react-app-3.git'
Here's my application code:
const path = require('path');
const express = require('express');
const app = express();
const publicPath = path.join(__dirname, '..','public');
const port = process.env.PORT || 3000;
app.use(express.static(publicPath));
app.get('*', (req,res) => {
res.sendFile(path.join(publicPath,'index.html'))
});
app.listen(port, () => {
console.log('Server is up');
});
after deleting yarn.lock
PS D:\react application> git push heroku master
Enumerating objects: 130, done.
Counting objects: 100% (130/130), done.
Delta compression using up to 4 threads
Compressing objects: 100% (121/121), done.
Writing objects: 100% (130/130), 2.56 MiB | 33.00 KiB/s, done.
Total 130 (delta 32), 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): 10.16.0
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 10.16.0...
remote: Downloading and installing node 10.16.0...
remote: Using default npm version: 6.9.0
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote:
remote: > node-sass#4.12.0 install /tmp/build_fa4b97b82e26e28c8efaef8a02fd356e/node_modules/node-sass
remote: > node scripts/install.js
remote:
remote: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.12.0/linux-x64-64_binding.node
remote: Download complete
remote: Binary saved to /tmp/build_fa4b97b82e26e28c8efaef8a02fd356e/node_modules/node-sass/vendor/linux-x64-64/binding.node
remote: Caching binary to /tmp/npmcache.jQpTT/node-sass/4.12.0/linux-x64-64_binding.node
remote:
remote: > core-js#2.6.9 postinstall /tmp/build_fa4b97b82e26e28c8efaef8a02fd356e/node_modules/core-js
remote: > node scripts/postinstall || echo "ignore"
remote:
remote:
remote: > uglifyjs-webpack-plugin#0.4.6 postinstall /tmp/build_fa4b97b82e26e28c8efaef8a02fd356e/node_modules/uglifyjs-webpack-plugin
remote: > node lib/post_install.js
remote:
remote:
remote: > node-sass#4.12.0 postinstall /tmp/build_fa4b97b82e26e28c8efaef8a02fd356e/node_modules/node-sass
remote: > node scripts/build.js
remote:
remote: Binary found at /tmp/build_fa4b97b82e26e28c8efaef8a02fd356e/node_modules/node-sass/vendor/linux-x64-64/binding.node
remote: Testing binary
remote: Binary is fine
remote: added 1139 packages from 774 contributors and audited 16655 packages in 26.036s
remote: found 36 vulnerabilities (31 low, 2 moderate, 3 high)
remote: run `npm audit fix` to fix them, or `npm audit` for details
remote:
remote: -----> Build
remote: Detected both "build" and "heroku-postbuild" scripts
remote: Running heroku-postbuild
remote:
remote: > expensify#1.0.0 heroku-postbuild /tmp/build_fa4b97b82e26e28c8efaef8a02fd356e
remote: > yarn run build:prod
remote:
remote: sh: 1: yarn: not found
remote: npm ERR! file sh
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno ENOENT
remote: npm ERR! syscall spawn
remote: npm ERR! expensify#1.0.0 heroku-postbuild: `yarn run build:prod`
remote: npm ERR! spawn ENOENT
remote: npm ERR!
remote: npm ERR! Failed at the expensify#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.jQpTT/_logs/2019-06-11T22_03_49_679Z-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 heroku-react-app-3.
remote:
To https://git.heroku.com/heroku-react-app-3.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/heroku-react-app-3.git'
my scripts
"engines": {
"node":"10.16.0"
},
"scripts": {
"serve": "live-server public/",
"build": "webpack",
"build:dev": "webpack",
"build:prod": "webpack -p --env production",
"dev-server": "webpack-dev-server",
"test": "jest --config=jest.config.json",
"start": "node server/server.js",
"heroku-postbuild": "yarn run build:prod"
}
As given the problem is that you are having both package-lock.json and yarn.lock
The heroku uses other servers to deploy your app hence it needs to download the dependencies on that remote server.
As you have two dependencies files so heroku can not decide which one to use to download dependencies hence the error.
Delete the one that you are not using(generally yarn.json) and your app will be good to go.

heroku build succeed but url gives application error while heroku open

Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 327 bytes | 0 bytes/s, done.
Total 3 (delta 2), 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.11.1
remote: engines.npm (package.json): 5.6.0
remote:
remote: Resolving node version 8.11.1...
remote: Downloading and installing node 8.11.1...
remote: npm 5.6.0 already installed with node
remote:
remote: -----> Restoring cache
remote: Loading 2 from cacheDirectories (default):
remote: - node_modules
remote: - bower_components (not cached - skipping)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json + package-lock)
remote: up to date in 4.243s
remote:
remote: -----> Caching build
remote: Clearing previous node cache
remote: Saving 2 cacheDirectories (default):
remote: - node_modules
remote: - bower_components (nothing to cache)
remote:
remote: -----> Pruning devDependencies
remote: Skipping because npm 5.6.0 sometimes fails when running 'npm
prune' due to a known issue
remote: https://github.com/npm/npm/issues/19356
remote:
remote: You can silence this warning by updating to at least npm 5.7.1 in your package.json
remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-an-npm-version
remote:
remote: -----> Build succeeded!
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 28.5M
remote: -----> Launching...
remote: Released v6
remote: https://ashishkr.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/ashishkr.git
cfc5c8a..76b27d1 master -> master
I have also a Procfile in my project root and have like:
web: node server.js
on doing heroku config i get the following result :
MONGODB_URI: mongodb://:#ds163410.mlab.com:63410/ashishkr
i hide the username and password for the security concern but i am sure that the username and password which i have entered is absolutely correct!
in my package.json i have engines and start script also:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"engines": {
"node": "8.11.1",
"npm": "5.6.0"
},
Anykind of help is appreciated !!
Thanks !!

Resources