Issues deploying to Heroku - node.js

Cannot for the life of me figure out what's stopping my app from deploying to Heroku (update). The relevant error logs and package.json sections are below. Some things I've tried are updating and de-updating all my packages, adding engine specifications for node and npm to the package.json, removing a few packages to see if they were interfering (the first time it failed there was error message about TipTap, a WYSIWYG editor on my app, also one attempt indicated it might be Tailwind), and I've deleted and reinstalled the node modules and package-lock files.
Heroku activity log:
...
remote: > bufferutil#4.0.7 install /tmp/build_c2557cec/client/node_modules/react-scripts/node_modules/webpack-plugin-serve/node_modules/bufferutil
remote: > node-gyp-build
remote:
remote: npm ERR! Linux 4.4.0-1104-aws
remote: npm ERR! argv "/tmp/build_c2557cec/.heroku/node/bin/node" "/tmp/build_c2557cec/node_modules/.bin/npm" "install"
remote: npm ERR! node v19.5.0
remote: npm ERR! npm v2.15.12
remote: npm ERR! path /tmp/build_c2557cec/client/node_modules/tailwindcss/node_modules/#types/node/package.json
remote: npm ERR! code ENOTDIR
remote: npm ERR! errno -20
remote: npm ERR! syscall open
remote:
remote: npm ERR! ENOTDIR: not a directory, open '/tmp/build_c2557cec/client/node_modules/tailwindcss/node_modules/#types/node/package.json'
...
My package.json engines and dependences:
...
"engines": {
"node": "19.x",
"npm": "8.x"
},
"private": false,
"dependencies": {
"#emailjs/browser": "^3.7.0",
"autoprefixer": "^10.4.7",
"axios": "^0.27.2",
"html-react-parser": "^3.0.4",
"postcss": "^8.4.14",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-icons": "^4.4.0",
"react-paginate": "^8.1.3",
"react-router-dom": "^6.7.0",
"react-scripts": "^5.0.1",
"tailwindcss": "^3.1.6"
},
...

Related

Could not resolve dependency with sanity in nextjs app

I am trying to deploy my next.js project, but I keep getting the following error with everything I do:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: rcd_drone#0.1.0
npm ERR! Found: #sanity/client#3.4.1
npm ERR! node_modules/#sanity/client
npm ERR! #sanity/client#"^3.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #sanity/client#"^2.11.0" from next-sanity-image#3.2.1
npm ERR! node_modules/next-sanity-image
npm ERR! next-sanity-image#"^3.2.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
I also have the following dependencies:
{
"name": "rcd_drone",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"#babel/core": "^7.17.9",
"#sanity/client": "^3.2.0",
"#sanity/image-url": "^1.0.1",
"#stripe/stripe-js": "^1.25.0",
"canvas-confetti": "^1.5.1",
"next": "^12.1.0",
"next-sanity-image": "^3.2.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-hot-toast": "^2.2.0",
"react-icons": "^4.3.1",
"frontmatter-markdown-loader": "^3.6.3",
"stripe": "^8.209.0"
},
"devDependencies": {
"#babel/preset-react": "^7.16.7",
"eslint": "8.13.0",
"eslint-config-next": "12.1.4"
}
}
Try doing the npm install --legacy-peer-deps within the Vercel project deploy page.
When deploying your project, go to the "build and output" settings, then in the npm command input write: npm install --legacy-peer-deps.
Select the override radio button, then try deploying.
Try deleting node_modules folder and package-lock.json file and run:
npm install --legacy-peer-deps
This is going to make fresh installation of the modules.

Get TypeError When deploying A Mean.js Project into Heroku

This is an old mean.js project. The project node version 4.4.4. I can run this project on my local machine using node 10.24.1.
When I deploy this project in heroku, many TypeErrors come in terminal while node-modules packages downloading. I followed some answers to solve this problem but unfortunately I can not succeed that is why I ask here.
My package-lock file is updated.
The Build Logs are as follows:
Enumerating objects: 28099, done.
Counting objects: 100% (28099/28099), done.
Delta compression using up to 6 threads
Compressing objects: 100% (15109/15109), done.
Writing objects: 100% (28099/28099), 58.86 MiB | 343.00 KiB/s, done.
Total 28099 (delta 10970), reused 27836 (delta 10797), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Deleting 1 files matching .slugignore patterns.
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): 4.4.4
remote: engines.npm (package.json): 3.8.x
remote:
remote: Resolving node version 4.4.4...
remote: Downloading and installing node 4.4.4...
remote: Bootstrapping npm 3.8.x (replacing 2.15.1)...
remote: npm 3.8.x installed
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote: npm ERR! Linux 4.4.0-1101-aws
remote: npm ERR! argv "/tmp/build_648a0567/.heroku/node/bin/node" "/tmp/build_648a0567/.heroku/node/bin/npm" "install" "--production=false" "--unsafe-perm" "--userconfig" "/tmp/build_648a0567/.npmrc"
remote: npm ERR! node v4.4.4
remote: npm ERR! npm v3.8.9
remote: npm ERR! code EMISSINGARG
remote:
remote: npm ERR! typeerror Error: Missing required argument #1
remote: npm ERR! typeerror at andLogAndFinish (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:31:3)
remote: npm ERR! typeerror at fetchPackageMetadata (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:51:22)
remote: npm ERR! typeerror at resolveWithNewModule (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/install/deps.js:455:12)
remote: npm ERR! typeerror at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/install/deps.js:456:7
remote: npm ERR! typeerror at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/node_modules/iferr/index.js:13:50
remote: npm ERR! typeerror at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:37:12
remote: npm ERR! typeerror at addRequestedAndFinish (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:82:5)
remote: npm ERR! typeerror at returnAndAddMetadata (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:118:7)
remote: npm ERR! typeerror at pickVersionFromRegistryDocument (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:135:20)
remote: npm ERR! typeerror at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/node_modules/iferr/index.js:13:50
remote: npm ERR! typeerror This is an error with npm itself. Please report this error at:
remote: npm ERR! typeerror <http://github.com/npm/npm/issues>
remote: npm ERR! Linux 4.4.0-1101-aws
remote: npm ERR! argv "/tmp/build_648a0567/.heroku/node/bin/node" "/tmp/build_648a0567/.heroku/node/bin/npm" "install" "--production=false" "--unsafe-perm" "--userconfig" "/tmp/build_648a0567/.npmrc"
remote: npm ERR! node v4.4.4
remote: npm ERR! npm v3.8.9
remote: npm ERR! code EMISSINGARG
remote:
remote: npm ERR! typeerror Error: Missing required argument #1
remote: npm ERR! typeerror at andLogAndFinish (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:31:3)
remote: npm ERR! typeerror at fetchPackageMetadata (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:51:22)
remote: npm ERR! typeerror at resolveWithNewModule (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/install/deps.js:455:12)
remote: npm ERR! typeerror at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/install/deps.js:456:7
remote: npm ERR! typeerror at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/node_modules/iferr/index.js:13:50
remote: npm ERR! typeerror at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:37:12
remote: npm ERR! typeerror at addRequestedAndFinish (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:82:5)
remote: npm ERR! typeerror at returnAndAddMetadata (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:118:7)
remote: npm ERR! typeerror at pickVersionFromRegistryDocument (/tmp/build_648a0567/.heroku/node/lib/node_modules/npm/lib/fetch-package-metadata.js:135:20)
remote: npm ERR! typeerror at /tmp/build_648a0567/.heroku/node/lib/node_modules/npm/node_modules/iferr/index.js:13:50
remote: npm ERR! typeerror This is an error with npm itself. Please report this error at:
remote: npm ERR! typeerror <http://github.com/npm/npm/issues>
remote:
remote: npm ERR! Please include the following file with any support request:
remote: npm ERR! /tmp/build_648a0567/npm-debug.log
remote:
remote: -----> Build failed
package.json file
{
"name": "...",
"description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js",
"version": "0.0.1",
"author": "...",
"engines": {
"node": "4.4.4",
"npm": "3.8.x"
},
"scripts": {
"start": "grunt",
"debug": "grunt debug",
"test": "grunt test",
"postinstall": "bower install --config.interactive=false"
},
"dependencies": {
"async": "~0.9.0",
"body-parser": "~1.9.0",
"bower": "~1.3.8",
"chalk": "~0.5",
"compression": "~1.2.0",
"connect-flash": "~0.1.1",
"connect-mongo": "^1.1.0",
"connect-mongodb-session": "^2.1.1",
"consolidate": "~0.10.0",
"cookie-parser": "~1.3.2",
"dotenv": "^16.0.0",
"express": "^4.13.4",
"express-session": "^1.13.0",
"forever": "~0.11.0",
"glob": "~4.0.5",
"gridfs-stream": "^1.1.1",
"grunt-cli": "~0.1.13",
"helmet": "~0.5.0",
"lodash": "^4.12.0",
"method-override": "~2.3.0",
"mongoose": "4.7.3",
"morgan": "~1.4.1",
"multer": "^1.1.0",
"nodemailer": "~2.4.1",
"passport": "~0.2.0",
"passport-facebook": "~1.0.2",
"passport-github": "~0.1.5",
"passport-google-oauth": "~0.1.5",
"passport-linkedin": "~0.1.3",
"passport-local": "~1.0.0",
"passport-twitter": "~1.0.2",
"paypal-rest-sdk": "^1.6.8",
"q": "^1.5.1",
"stripe": "^4.6.0",
"swig": "~1.4.1",
"validator": "^5.2.0"
},
"devDependencies": {
"grunt": "^1.0.1",
"grunt-concurrent": "^2.3.0",
"grunt-contrib-csslint": "^1.0.0",
"grunt-contrib-cssmin": "^1.0.1",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-uglify": "^1.0.1",
"grunt-contrib-watch": "^1.0.0",
"grunt-env": "^0.4.4",
"grunt-karma": "^1.0.0",
"grunt-mocha-test": "^0.12.7",
"grunt-ng-annotate": "^2.0.2",
"grunt-nodemon": "^0.4.2",
"karma": "^0.13.22",
"karma-chrome-launcher": "^1.0.1",
"karma-coverage": "^1.0.0",
"karma-firefox-launcher": "^0.1.7",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.0",
"load-grunt-tasks": "^3.5.0",
"mocha": "^2.4.5",
"should": "^8.3.1",
"supertest": "^1.2.0"
}
}
As this project is run on node 10.24.1 on my local machine, it can build on heroku if heroku's node version is downgraded into 10.24.1 at runtime (if possible), I assume but I am not sure.
Please anyone answer this question or suggestion? Thanks in advance!
Node.js 4.4.4 is absolutely ancient.
It doesn't even show up on this page of releases, which says in part:
After six months, odd-numbered releases (9, 11, etc.) become unsupported, and even-numbered releases (10, 12, etc.) move to Active LTS status and are ready for general use. LTS release status is "long-term support", which typically guarantees that critical bugs will be fixed for a total of 30 months.
Version 4.4 is well beyond its maintenance window, and I strongly urge you to upgrade this project.
Having said that, there's a good chance you can get Heroku to run Node.js 10 to match your local version. Heroku only officially supports the current and active LTS releases, but it doesn't prevent you from using older releases:
Since Heroku is based on a standard Ubuntu Linux stack, you can run most Node versions (>= 0.10.0) on the platform. However, the testing and support focus of the buildpack will be oriented around active LTS and Stable releases.
Update the engines section in your package.json:
"engines": {
"node": "10.x"
},
I have also removed the npm version here, which should cause Heroku to use whatever version is bundled with the latest Node.js 10.x release.
Commit this change, then redeploy.

Heroku Shopify Application Error 'npm ERR! ERESOLVE unable to resolve dependency tree'

Greetings I have a problem with Heroku because it's don't want to install legacy packages for my Shopify app, my Shopify app is on Github and I just set up everything that my application needs, but when I deploy the main branch on Heroku I get this error in Heroku console below, can someone help me fix this?
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
USE_NPM_INSTALL=true
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 16.x...
Downloading and installing node 16.14.0...
Using default npm version: 8.3.1
-----> Restoring cache
Caching has been disabled because NODE_MODULES_CACHE=false
-----> Installing dependencies
Installing node modules (package.json + package-lock)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: shopify-app-node#1.0.0
npm ERR! Found: react#16.14.0
npm ERR! node_modules/react
npm ERR! react#"^16.10.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^17.0.2 || ^18.0.0-0" from next#12.0.10
npm ERR! node_modules/next
npm ERR! next#"^12.0.2" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /tmp/npmcache.CTfHl/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.CTfHl/_logs/2022-02-10T12_18_50_156Z-debug-0.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
My package.json
{
"name": "shopify-app-node",
"version": "1.0.0",
"description": "Shopify's node app for CLI tool",
"scripts": {
"test": "jest",
"dev": "cross-env NODE_ENV=development nodemon ./server/index.js --watch ./server/index.js",
"build": "NEXT_TELEMETRY_DISABLED=1 next build",
"start": "cross-env NODE_ENV=production node ./server/index.js"
},
"engines": {
"node": "16.14.0",
"npm": "8.4.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Shopify/shopify-app-node.git"
},
"author": "Shopify Inc.",
"license": "MIT",
"bugs": {
"url": "https://github.com/shopify/shopify-app-node/issues"
},
"dependencies": {
"#babel/core": "7.12.10",
"#babel/polyfill": "^7.6.0",
"#babel/preset-env": "^7.12.11",
"#babel/register": "^7.12.10",
"#shopify/app-bridge-react": "^2.0.2",
"#shopify/app-bridge-utils": "^2.0.2",
"#shopify/koa-shopify-auth": "^4.1.2",
"#shopify/polaris": "^6.2.0",
"apollo-boost": "^0.4.9",
"axios": "^0.25.0",
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
"graphql": "^14.5.8",
"isomorphic-fetch": "^3.0.0",
"koa": "^2.13.1",
"koa-bodyparser": "^4.3.0",
"koa-compress": "^5.1.0",
"koa-cors": "0.0.16",
"koa-logger": "^3.2.1",
"koa-router": "^10.0.0",
"koa-session": "^6.1.0",
"mysql2": "^2.3.3",
"next": "^12.0.2",
"next-env": "^1.1.0",
"node-fetch": "^2.6.7",
"react": "^16.10.1",
"react-apollo": "^3.1.3",
"react-dom": "^16.10.1",
"sequelize": "^6.13.0",
"slugify": "^1.6.5",
"validator": "^13.7.0",
"webpack": "^4.44.1"
},
"devDependencies": {
"#babel/plugin-transform-runtime": "^7.12.10",
"#babel/preset-stage-3": "^7.0.0",
"babel-jest": "26.6.3",
"babel-register": "^6.26.0",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.6",
"husky": "^4.3.6",
"jest": "26.6.3",
"lint-staged": "^10.5.4",
"nodemon": "^2.0.7",
"prettier": "2.2.1",
"react-addons-test-utils": "15.6.2",
"react-test-renderer": "16.14.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,css,json,md}": [
"prettier --write"
]
}
}
If you cannot reproduce locally, set package.json engines: to match your local development
This is not the OP's exact issue as they had specified engines: and reproduced locally, so definitely what they needed was to resolve it locally first, which is a subset of the infinite Unable to resolve dependency tree error when installing npm packages
But I couldn't reproduce locally even after delting node_modules and package-lock.json, so as soon as I set engines:, which Heroku respects, to match my local working setup node --version and npm --version with:
"engines": {
"node": "14.17.0",
"npm": "6.14.13"
},
it started working on Heroku. Here's my failing package.json to which the engines were added. The error was:
remote: Installing node modules (package.json)
remote: npm ERR! code ERESOLVE
remote: npm ERR! ERESOLVE unable to resolve dependency tree
remote: npm ERR!
remote: npm ERR! While resolving: conduit-node#1.0.0
remote: npm ERR! Found: react#17.0.2
remote: npm ERR! node_modules/react
remote: npm ERR! react#"17.0.2" from the root project
remote: npm ERR!
remote: npm ERR! Could not resolve dependency:
remote: npm ERR! peer react#"^16.11.0" from swr#0.3.0
remote: npm ERR! node_modules/swr
remote: npm ERR! swr#"0.3.0" from the root project
Prior to the fix, Heroku logs show it was using:
remote: Downloading and installing node 16.14.0...
remote: Using default npm version: 8.3.1
For this reason, you should Always, Always, set engines to match your local setup on a Heroku project.
Ciro Santilli's way solved my problem:
I added these lines to package.json and the problem fixed:
"engines": {
"node": "16.x",
"npm": "8.5.5"
},
Apparently for me the "knex" module that I use is not compatible with newer npm (I am not sure).
You may use .npmrc
New versions of npm do not allow you to install dependencies with different versions of peer dependencies because it may lead to breaking change. So if you are sure that everything works without any issues, maybe you have good tests. Just add --legacy-peer-deps or --force after your npm script (basically it's npm i). But it's so annoying to write it, instead you can create '.npmrc' file in the root of your project with following:
legacy-peer-deps=true
...
or even:
force=true
...
Now you don't need to add --legacy-peer-deps or --force manually.
ps. It also solves the problem with Heroku when you cannot explicitly use npm i --legacy-peer-deps. At least I don't know how to do so.
I found a solution. You can add config variables in Heroku apps.
Go to the app in Heroku -> settings -> Reveal Config Vars
Add a new config var with the key: NPM_CONFIG_LEGACY_PEER_DEPS and value true, and then redeploy.
I install these old packages with npm install --force
I run npm outdated
I see what packages are in red
I do upgrade from the current version to the wanted version with npm install --save packagename#wanted_version
Remove any empty files that you may have in your project
Uploaded to git
Deploy to Heroku
Your lock file contains conflicting dependencies. Since you were able to reproduce the error locally using npm ci we have a good way to test a fix locally.
It looks like you are depending directly on React 16. Is that something that you need directly, or is it just a dependency for Next.js?
If it's not something you need directly, upgrade it per the Next.js docs:
npm install react#latest react-dom#latest
That should modify your package-lock.json. Then try installing from the lock file again with npm ci. If that fixes things, commit the change and redeploy.
On the other hand, if you are directly depending on React 16 and cannot upgrade you'll have to consider rolling back to an earlier version of Next.js.

Heroku, push rejected

I am getting following error while trying to push my project to Heroku:
-----> 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=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 14.x...
Downloading and installing node 14.17.3...
Using default npm version: 6.14.13
-----> Restoring cache
Caching has been disabled because NODE_MODULES_CACHE=false
-----> Installing dependencies
Installing node modules
added 118 packages in 2.552s
-----> Build
Running heroku-postbuild
> market#1.0.1 heroku-postbuild /tmp/build_ece853b3
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
> core-js#2.6.12 postinstall /tmp/build_ece853b3/client/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js#3.13.1 postinstall /tmp/build_ece853b3/client/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js-pure#3.13.1 postinstall /tmp/build_ece853b3/client/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
> ejs#2.7.4 postinstall /tmp/build_ece853b3/client/node_modules/ejs
> node ./postinstall.js
added 1784 packages from 799 contributors and audited 1888 packages in 44.428s
137 packages are looking for funding
run `npm fund` for details
found 86 vulnerabilities (83 moderate, 3 high)
run `npm audit fix` to fix them, or `npm audit` for details
> client#0.1.0 build /tmp/build_ece853b3/client
> react-scripts build
Creating an optimized production build...
Failed to compile.
./src/App.scss
Cannot find module 'sass'
Require stack:
- /tmp/build_ece853b3/client/node_modules/sass-loader/dist/utils.js
- /tmp/build_ece853b3/client/node_modules/sass-loader/dist/index.js
- /tmp/build_ece853b3/client/node_modules/sass-loader/dist/cjs.js
- /tmp/build_ece853b3/client/node_modules/loader-runner/lib/loadLoader.js
- /tmp/build_ece853b3/client/node_modules/loader-runner/lib/LoaderRunner.js
- /tmp/build_ece853b3/client/node_modules/webpack/lib/NormalModule.js
- /tmp/build_ece853b3/client/node_modules/webpack/lib/NormalModuleFactory.js
- /tmp/build_ece853b3/client/node_modules/webpack/lib/Compiler.js
- /tmp/build_ece853b3/client/node_modules/webpack/lib/webpack.js
- /tmp/build_ece853b3/client/node_modules/react-scripts/scripts/build.js
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.nm2I7/_logs/2021-07-14T00_48_14_758Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! market#1.0.1 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 market#1.0.1 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.nm2I7/_logs/2021-07-14T00_48_14_782Z-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
Some possible problems:
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
- A module may be missing from 'dependencies' in package.json
https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
I made a spelling mistake in package.json link. after correcting it I tried pushing the project to the heroku but getting error push failed. Locally the project is working fine.
here are dependencies in my root
package.json
"dependencies": {
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.13.2",
"morgan": "^1.10.0",
"multer": "^1.4.2"
}
and client side dependencies:
"dependencies": {
"#testing-library/jest-dom": "^5.12.0",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^13.1.9",
"axios": "^0.21.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-paypal-button-v2": "^2.6.3",
"react-redux": "^7.2.4",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3",
"redux": "^4.1.0",
"redux-devtools-extension": "^2.13.9",
"redux-thunk": "^2.3.0",
"web-vitals": "^1.1.2"
},
"devDependencies": {
"node-sass": "^6.0.1"
}
Please help.
thanks
The problem was node-sass was not getting installed so I added:
"postinstall": "npm rebuild node-sass && npm install --unsafe-perm -f node-sass"
inside root package.json under scripts{}

Error while trying to deploy React app to Heroku

I'm keep getting the following error when I'm trying to deploy to heroku:
remote: sh: 1: react-scripts: Permission denied
The app compiles and workes well locally, so i'm pretty sure it's something with the deployment settings.
I can't understand what's wrong... here is my nodejs server package.json:
{
"name": "app-server",
"version": "1.0.0",
"description": "Create-react-app with Express",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js",
"heroku-postbuild": "cd client && npm install && npm run build"
},
"author": "Roy",
"license": "ISC",
"dependencies": {
"axios": "^0.19.0",
"cors": "^2.8.4",
"dotenv": "^8.1.0",
"express": "^4.16.3"
},
"engines": {
"node": "10.5.0"
}
}
And here is my client package.json
{
"name": "client",
"version": "0.1.0",
"private": false,
"dependencies": {
"#material-ui/core": "^4.4.1",
"axios": "^0.19.0",
"color-temperature": "^0.2.7",
"concurrently": "^4.1.2",
"cors": "^2.8.5",
"downshift": "^3.2.14",
"express": "^4.17.1",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"path": "^0.12.7",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-md": "^1.12.3",
"react-moment": "^0.9.2",
"react-redux": "^7.0.2",
"react-reveal": "^1.2.2",
"react-router-dom": "^5.0.0",
"react-scripts": "2.1.8",
"react-toastify": "^5.3.2",
"reactstrap": "^8.0.1",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000"
}
And here is the full error
remote: sh: 1: react-scripts: Permission denied
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! client#0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 126
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.cG6aC/_logs/2019-09-20T12_27_39_563Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! weather-app-server#1.0.0 heroku-postbuild: `cd client && npm install && npm run
build`
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the weather-app-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.cG6aC/_logs/2019-09-20T12_27_39_576Z-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
Have you ignored node modules?
Have you checked that all module installations were correct without errors?
In your client package.json the proxy is localhost. Try to replace it with your backend url.

Resources