Im trying to deploy using Heroku, but im getting an error regarding node-sass, importing sass files.
its seems to be a common problem with node-sass, but I couldn't find why the import of scss files is causing the problem. I've re-installed node-sass but that didn't help.
//package.json
{
"name": "crown-clothing",
"version": "0.1.0",
"private": true,
"dependencies": {
"firebase": "^6.3.5",
"node-sass": "^4.12.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-redux": "^7.1.0",
"react-router-dom": "^5.0.1",
"react-scripts": "3.0.1",
"react-stripe-checkout": "^2.6.3",
"redux": "^4.0.4",
"redux-logger": "^3.0.6",
"redux-persist": "^5.10.0",
"reselect": "^4.0.0"
},
"scripts": {
"start": "BROWSER=firefox react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
//error message
Creating an optimized production build...
remote: Failed to compile.
remote:
remote: ./src/components/directory/directory.styles.scss
remote: To import Sass files, you first need to install node-sass.
remote: Run `npm install node-sass` or `yarn add node-sass` inside your workspace.
remote:
remote:
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! crown-clothing#0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the crown-clothing#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.7gDk8/_logs/2019-08-26T17_18_16_441Z-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
As you can see, the import of sass files is what causing the problem.
Weirdly enough, all I had to do was remove my node-modules folder, reinstall node-sass, and push to github before pushing to heroku. I can't say that they were all necessary but it is working, and didn't have to convert and css filetypes.
So after trying several things like clearing Heroku cache, re-installing node-models and re-deploy that didn't seem to work, I took the following steps:
change all of my .css files to .sass files.
install node-sass(which I already had) and then updating my git repository to the newest version of the app. that did the trick!
Related
Heroku errors:
Total 13 (delta 9), 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): 16.x
remote: engines.npm (package.json): unspecified (use default)
remote: Resolving node version 16.x...
remote: Downloading and installing node 16.16.0...
remote: Using default npm version: 8.11.0
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote: npm ERR! code ERESOLVE
remote: npm ERR! ERESOLVE could not resolve
remote: npm ERR! While resolving: #reach/combobox#0.16.5
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! peer react#"^16.8 || ^17 || ^18" from #react-google-maps/api#2.12.0
remote: npm ERR! node_modules/#react-google-maps/api
remote: npm ERR! #react-google-maps/api#"^2.12.0" from the root project
remote: npm ERR! 9 more (#testing-library/react, react-avatar, react-dom, ...)
remote: npm ERR! Could not resolve dependency:
remote: npm ERR! peer react#"^16.8.0 || 17.x" from #reach/combobox#0.16.5
remote: npm ERR! node_modules/#reach/combobox
remote: npm ERR! #reach/combobox#"^0.16.5" from the root project
remote: npm ERR!
remote: npm ERR! Conflicting peer dependency: react#17.0.2
remote: npm ERR! node_modules/react
remote: npm ERR! peer react#"^16.8.0 || 17.x" from #reach/combobox#0.16.5
remote: npm ERR! node_modules/#reach/combobox
remote: npm ERR! #reach/combobox#"^0.16.5" from the root project
I am trying to deploy this react mern-stack app to heroku for class, which uses certain google map api and dependencies. I tried --legacy-peer-deps and even --force (force completely broke my code), tried almost everything. Nothing seems to be working. Been trying at this for a while now and am completely blocked. I don't know what else to do. I appreciate any insight to this.
Heres my package.json
{
"name": "find-furry-friends",
"version": "0.1.0",
"engines": {
"node": "16.x"
},
"private": true,
"dependencies": {
"#hookform/resolvers": "^2.9.4",
"#reach/combobox": "^0.16.5",
"#react-google-maps/api": "^2.12.0",
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.3.0",
"#testing-library/user-event": "^13.5.0",
"bcrypt": "^5.0.1",
"bootstrap": "^5.1.3",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"jsonwebtoken": "^8.5.1",
"moment": "^2.29.4",
"mongoose": "^6.4.0",
"morgan": "^1.10.0",
"petfinder-client": "^1.0.2",
"react": "^18.2.0",
"react-avatar": "^5.0.1",
"react-dom": "^18.0.2",
"react-file-base64": "^1.0.3",
"react-router-dom": "^6.3.0",
"react-scripts": "^5.0.1",
"react-tilty": "^2.0.3",
"serve-favicon": "^2.5.0",
"use-places-autocomplete": "^4.0.0",
"web-vitals": "^2.1.4",
"yup": "^0.32.11"
},
"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"
]
},
"proxy": "http://localhost:3001"
}
The problem is that #reach/combobox wants an older version of React (either 16 0r 17) but you have React 18.2.0 installed at the top level of your package.json. Try downgrading React to version 17:
npm install react#17
Then push to Heroku again.
I am attempting to install React with Typescript, but I keep getting a weird error.
Please note myprojectname is the root repository directory that I am installing the React app into. For some reason it is trying to resolve myprojectname#0.1.0?
Error
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1355 packages in 1m
171 packages are looking for funding
run `npm fund` for details
Installing template dependencies using npm...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: myprojectname#0.1.0
npm ERR! Found: react#18.0.0
npm ERR! node_modules/react
npm ERR! react#"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"<18.0.0" from #testing-library/react#12.1.5
npm ERR! node_modules/#testing-library/react
npm ERR! #testing-library/react#"^12.0.0" from the root project
My attempts to solve the issue
Clearing then verifying npx cache
Uninstalling create-react-app globally.
Updating npm
Updating node
Running command with and without #latest
Running command with and without --template typescript
Using the --use-npm flag.
Adding --legacy-peer-deps to command.
Modifying command to create the react app in a nested directory.
Command
npx create-react-app#latest . --template typescript --use-npm
Outputs
npm -v > 8.6.0
node -v > v17.8.0
Package.json
{
"name": "myprojectname",
"version": "0.1.0",
"private": true,
"dependencies": {
"cra-template-typescript": "1.1.3",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-scripts": "5.0.0"
},
"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"
]
}
}
The problem was caused by an issue with the testing library installed by default with React. It may have already been fixed.
I'm trying to deploy my create-react-app using Heroku. When I do git push heroku master, the build fails.
This is the error log:
-----> React.js (create-react-app) multi app detected
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-multi.git
=====> Detected Framework: Multipack
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-nodejs.git
=====> Detected Framework: Node.js
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.16.3...
Using default npm version: 6.14.4
-----> Installing dependencies
Installing node modules (package.json + package-lock)
> nodemailer#6.4.6 postinstall /tmp/build_258ba2b79ac9e7091bc7dd79a031dd4f/node_modules/nodemailer
> node -e "try{require('./postinstall')}catch(e){}"
=== Nodemailer 6.4.6 ===
Thank you for using Nodemailer for your email sending needs! While Nodemailer
itself is mostly meant to be a SMTP client there are other related projects in
the Nodemailer project as well.
For example:
> IMAP API ( https://imapapi.com ) is a server application to easily access
IMAP accounts via REST API
> NodemailerApp ( https://nodemailer.com/app/ ) is a cross platform GUI app to
debug emails
> styled-components#4.2.0 postinstall /tmp/build_258ba2b79ac9e7091bc7dd79a031dd4f/node_modules/styled-components
> node ./scripts/postinstall.js || exit 0
Use styled-components at work? Consider supporting our development efforts at https://opencollective.com/styled-components
added 1914 packages from 1179 contributors and audited 2053 packages in 49.627s
1 package is looking for funding
run `npm fund` for details
found 56466 vulnerabilities (39341 low, 26 moderate, 17098 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for details
-----> Build
Running build
> juliesong#0.1.0 build /tmp/build_258ba2b79ac9e7091bc7dd79a031dd4f
> react-scripts build
Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run next command `npm update`
Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
Failed to compile.
./src/components/PageIntro.js
Cannot find module: 'axios'. Make sure this package is installed.
You can install this package by running: npm install axios.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! juliesong#0.1.0 build: `react-scripts build `
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the juliesong#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.6BFeR/_logs/2020-05-17T06_58_22_399Z-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 React.js (create-react-app) multi app.
! Push failed
Here's my package.json file, in case it helps:
{
"name": "juliesong",
"version": "0.1.0",
"private": true,
"homepage": "https://www.juliesong.me",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1",
"nodemailer": "^6.4.6",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-preloaders": "^3.0.3",
"react-responsive": "^6.1.2",
"react-responsive-carousel": "^3.1.49",
"react-responsive-simple": "^0.1.2",
"react-router-dom": "^4.1.1",
"react-router-hash-link": "^1.2.1",
"react-scripts": "^3.0.0",
"styled-components": "^4.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build ",
"test": "react-scripts test",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 9009 -s public",
"build-storybook": "build-storybook -s public",
"predeploy": "npm run build && cp build/index.html build/404.html",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"#babel/core": "^7.4.3",
"#storybook/addon-actions": "^5.0.6",
"#storybook/addon-links": "^5.0.6",
"#storybook/addons": "^5.0.6",
"#storybook/react": "^5.0.6",
"babel-loader": "^8.0.5",
"gh-pages": "^2.2.0"
},
"description": "This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/jiyoonee/Website-Portfolio.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/jiyoonee/Website-Portfolio/issues"
}
}
I did try to work around with gh-pages but it didn't seem to work so I tried switching to Heroku. It's my first time using it so any help on this issue would be appreciated. Thanks!
newbie here - first time trying to push react frontend to heroku. i have tried what heroku has asked for and is still not working. think i made it worse by implementing suggestions when googling...(btw i have this is my index.js file: import {Provider} from 'react-redux')
following list of errors
♥ git push heroku master
Enumerating objects: 39, done.
Counting objects: 100% (39/39), done.
Delta compression using up to 8 threads
Compressing objects: 100% (37/37), done.
Writing objects: 100% (39/39), 140.24 KiB | 6.37 MiB/s, done.
Total 39 (delta 5), 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: NPM_CONFIG_PRODUCTION=true
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 10.x...
remote: Downloading and installing node 10.16.3...
remote: Using default npm version: 6.9.0
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote:
remote: > core-js#2.6.9 postinstall /tmp/build_59a9e22c84972b1649248fcdd072b559/node_modules/babel-runtime/node_modules/core-js
remote: > node scripts/postinstall || echo "ignore"
remote:
remote:
remote: > core-js-pure#3.1.4 postinstall /tmp/build_59a9e22c84972b1649248fcdd072b559/node_modules/core-js-pure
remote: > node scripts/postinstall || echo "ignore"
remote:
remote: added 1386 packages from 676 contributors and audited 902051 packages in 34.626s
remote: found 2 vulnerabilities (1 high, 1 critical)
remote: run `npm audit fix` to fix them, or `npm audit` for details
remote:
remote: -----> Build
remote: Running build
remote:
remote: > kayaks#0.1.0 build /tmp/build_59a9e22c84972b1649248fcdd072b559
remote: > react-scripts build
remote:
remote: Creating an optimized production build...
remote: Failed to compile.
remote:
remote: ./src/index.js
remote: Cannot find module: 'react-redux'. Make sure this package is installed.
remote:
remote: You can install this package by running: npm install react-redux.
remote:
remote:
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! kayaks#0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the kayaks#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.P3JWe/_logs/2019-10-08T00_50_49_274Z-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: - 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 kayaks-frontend.
remote:
package.json
{
"name": "kayaks",
"version": "0.1.0",
"private": true,
"engines": {
"npm": "6.11.3",
"node": "12.11.0",
},
"dependencies": {
"cuid": "^1.3.8",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-date-picker": "^7.8.1",
"react-datepicker": "^2.8.0",
"react-dom": "^16.8.6",
"react-dropdown-select": "^3.3.1",
"react-redux": "^7.1.1",
"react-router-dom": "^5.0.1",
"react-scripts": "3.0.1",
"react-semantic-ui-datepickers": "^1.11.0",
"redux": "^4.0.4",
"redux-form": "^8.1.0",
"redux-thunk": "^2.3.0",
"semantic-ui": "^2.4.2",
"semantic-ui-calendar-react": "^0.15.2",
"semantic-ui-css": "2.4.1",
"semantic-ui-react": "^0.87.3",
"typescript": "^3.6.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Cannot find module: 'react-redux'. Make sure this package is installed
This is your problem. Have you installed this? Try running npm i and then deploying.
To host a create-react-app on Heroku you must serve the /build folder. You can do it very easily with a node.js express server.
First you'll need to install express so you can run npm i express --save or yarn add express.
Then just add a server.js file to the root of your project serving the /build folder as static content and routing all request to /build/index.html.
const path = require('path');
const express = require('express');
const app = express();
const port = process.env.PORT || 3000;
app.use(express.static(path.join(__dirname, 'build')));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'build/index.html'));
});
app.listen(port, () => {
console.log(`The server is running on port ${port}!`);
});
Lastly, you need to update your npm run start script to node server.js, and use react-scripts start only during development.
"scripts": {
"start": "node server.js",
"dev": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Heroku will run your npm run build and then your npm run start scripts when a new version is deployed.
I'm trying to deploy a react app to Heroku, but I keep getting the error "Push rejected, failed to compile Node.js app".
I've looked back at the other two react-apps I've deployed to Heroku to see if I forgot to add anything and I can't find any discrepancies. I see that it says it can't locate the index.html file, but I see that it is there. I then see something about "failing at portfolio#.1.0 build".
-----> Build
remote: Running build
remote:
remote: > portfolio#0.1.0 build
/tmp/build_fcb9f920aefd93116879e7ef6c75d3cc
remote: > react-scripts build
remote:
remote: Could not find a required file.
remote: Name: index.html
remote: Searched in:
/tmp/build_fcb9f920aefd93116879e7ef6c75d3cc/public
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! portfolio#0.1.0 build: `react-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the portfolio#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.L4l4f/_logs/2019-09-
03T15_47_28_491Z-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
remote: help: https://help.heroku.com/
remote:
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 arcane-earth-93557.
Here is my package.json file as well
{
"name": "portfolio",
"version": "0.1.0",
"private": true,
"engines": {
"npm": "6.9.0",
"node": "10.16.0"
},
"dependencies": {
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-icons": "^3.7.0",
"react-router": "^2.0.1",
"react-router-dom": "^5.0.1",
"react-scripts": "3.1.1",
"react-scroll": "^1.7.13"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I just want to know why I can't deploy.