I am trying to deploy my app to Heroku, it works in local but no luck online. I deleted and reinstalled node modules.
I had another error quite related to this (file not found same names etc) I changed the relative paths thinking that would fix the issue but I am getting nothing to come out of it
The error is:
Cannot find file './Components/SearchBar/SearchBar'
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import SearchBar from './Components/SearchBar/SearchBar'
import BusinessList from './Components/BusinessList/BusinessList'
import Business from './Components/Business/Business'
import Yelp from './Components/Util/Yelp'
I expected to not pull an error for something so simple, I've poured over the file and folder names and it just is not making sense.
PS I think it's probably unconnected I have const yelpApiKey=process.env.yelpApiKey for my heroku to connect to my API key (typed inside my account)
Thank you #Jason for asking this question and #Rakesh for answering.
I deployed create-react-app project on Heroku then I encountered a similar error where failed to build my project. the error was routes.js failed to import signup.js
Heroku log
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=false
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 10.16.3
engines.npm (package.json): unspecified (use default)
Resolving node version 10.16.3...
Downloading and installing node 10.16.3...
Using default npm version: 6.9.0
-----> Restoring cache
Caching has been disabled because NODE_MODULES_CACHE=false
-----> Installing dependencies
Installing node modules (package.json + package-lock)
> core-js#2.6.9 postinstall /tmp/build_5d506b6dfc93b7f4b6575e02cc682130/node_modules/babel-runtime/node_modules/core-js
> node scripts/postinstall || echo "ignore"
> core-js#3.2.1 postinstall /tmp/build_5d506b6dfc93b7f4b6575e02cc682130/node_modules/core-js
> node scripts/postinstall || echo "ignore"
added 1507 packages from 719 contributors and audited 905071 packages in 35.746s
found 0 vulnerabilities
-----> Build
Running build
> chat-app#0.1.0 build /tmp/build_5d506b6dfc93b7f4b6575e02cc682130
> react-scripts build
Creating an optimized production build...
Failed to compile.
./src/routes.js // my beautiful error here
Cannot find file './Components/User/signup/signup.js' in './src'.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chat-app#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chat-app#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.ynm0W/_logs/2019-09-30T15_24_32_571Z-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
solution
Heroku deploy projects on Linux servers, it means it is case sensitive if you make mistake the build will fail. I advise sticking with lowercase when naming files and directories.
my project structure
|root
|src
| componets
| user
| signup
|routes
|index.js
Alternatively,
After I correct mistakes, I still had the same error. so why?
I did not notice Git does not push the change. When you only rename the directory and even if you do git add, git commit and git push Git sometimes does not consider the changes. I advise after change go to the website to verify.
Lastly,
when deploying to Heroku please deploy only the base branch. for Example Master or develop. I realized every time I deployed my feature branch, Heroku automatic detect my base branch which was develop.
I found 2 problems with your code:
Import path is case sensitive(for some environments). And you are using 'Components' instead of 'components'
Import of 'App' in index.js is wrong. Use following
import App from './App';
In my case i renamed my file locally but when i pushed it on github it didn't reflected there. so i deleted that file and made new file with same content and it worked!
I tried all the suggestions above but none are working for me. Eventually, what I did was deleting the file that was complaining missing by heroku, and replaced it with a dummy component. After that, checked in my changes to heroku. Everything should be deployed successfully now.
Finally, I can swapped back my old dummy component with my original component and checked into heroku again and hallelujah, it worked !!!!
Hopefully that my workaround could save someone time :)
Thanks
This problem on Heroku is usually due to the fact that you renamed a component, like for example MyComponent into Mycomponent, and both git cache and heroku build cache may give that problem. The solution is this: Failed to compile: Cannot find file './containers/App/App' in './src' and clean the heroku build cache to to be safe:
https://help.heroku.com/18PI5RSY/how-do-i-clear-the-build-cache
Related
After cloning the repository I created and set my .env.local file, ran npm i then ran npm run dev. The server starts, env is loaded from .env.local however it immediately fails prompting me with the following:
error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
Error: Not supported
at Object.loadConfig [as default] (C:\Users\Nick\Desktop\rebuild\node_modules\next\dist\server\config.js:399:74)
at async NextServer.loadConfig (C:\Users\Nick\Desktop\rebuild\node_modules\next\dist\server\next.js:110:22)
at async NextServer.prepare (C:\Users\Nick\Desktop\rebuild\node_modules\next\dist\server\next.js:92:24)
at async C:\Users\Nick\Desktop\rebuild\node_modules\next\dist\cli\next-dev.js:126:9
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! rebuild#0.1.0 dev: `next dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the rebuild#0.1.0 dev 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! C:\Users\Nick\AppData\Roaming\npm-cache\_logs\2021-10-29T19_47_30_427Z-debug.log
The NextJS documentation says: See the error message in your terminal where you started next to see more context. however all it is telling me is Not Supported.
I'm not familiar with the error and was looking for guidance.
I ended up uninstalling Node and everything related to it. Reinstalled with Node v14.0.0 and it seemed to work.
Thanks all for your help!
I solved this by upgrading to the latest version of nodeJS
This error Error: Not supported is likely coming up because the installed Node.js version is not supported by the used Next.js version.
e.g. Next.js v12 doesn't support Node.js v10:
The minimum Node.js version has been bumped from 12.0.0 to 12.22.0, which is the first version of Node.js with native ES modules support
This version discrepancy can arise for several reasons, sometimes quite unexpected, and also seemingly "out of nowhere", because not only a "wrong" Node.js version can be installed, but also different Node.js versions can be installed in different paths.
Solutions:
(Note that after the below solutions you also might need to delete the folders .next and node_modules, and re-install the node modules again, e.g. yarn or npm install).
1. different computer
If you pull the repository on a different computer, where a different Node.js version is installed:
Solution: update Node.js to the supported version.
2. different environment
If you build the repository inside a different environment, where a different Node.js version is referenced (e.g. in Webstorm vs. a separate Terminal):
Solution: make sure you are using the correct environment, or use the correct path to Node.js, or update Node.js.
3. different build commands
If you use different build commands, which do or do not specify a (absolute) path to a specific node.js installation:
e.g. /usr/bin/node ... --> use absolute path to specific node.js installation.
e.g. node ... --> use node installation as specified in the $PATH environment variable, e.g. /home/(username)/.nvm/versions/node/v14.18.1/bin/node.
Solution: Modify the build script to use the correct path to Node.js, or update the Node.js version under the used path.
4. broken build setup
If for some reason the build setup in Webstorm gets lost or breaks, which apparently can happen sometimes, e.g. when switching branches:
(You can verify this by trying to build inside a separate terminal.)
Solution: Fix the build setup in Webstorm to use the correct Note.js path, or update Node.js under the used path.
I'm trying to create a webpage using Reactjs (for learning react js).
After I run the command npx create-react-app cars, I'm getting errors as follows:
npm WARN deprecated tar#2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
added 64 packages, and audited 107 packages in 15s
3 high severity vulnerabilities
To address all issues, run:
npm audit fix
Run "npm audit" for details.
After running npm audit, it says:
To address all issues (including breaking changes), run: npm audit fix --force
which gave the result as:
found 0 vulnerabilities
After following all these steps, when I try to create a project starting from create-react-app I'm getting same errors like:
x high severity vulnerabilities to address all issues, run: npm audit
I don't understand what I'm missing here. By all these I ended up creating 4 folders which has a subfolder node-modules and two JSON files named package and package-lock
Can anybody please direct me how do I proceed with all these?
npm version: 7.21.0
node version: v16.7.0
windows: 10
Below are the steps I followed to create my react environment and get ride of these warnings/errors are:
As per this answer, I have uninstalled ByteFence since as I mentioned here in the comments that there a threat detection and
Used this command npm set audit false from this answer
Apart from these steps, I made sure that I have latest versions of Node and npm installed
I am trying to create a react app on Heroku and I want to make use of vmsg (https://github.com/Kagami/vmsg).
I have set up a small app following these instructions:
https://github.com/mars/create-react-app-buildpack
Quick Start
I also ran:
npm install vmsg --save
I am now able to confirm that this file exists:
node_modules/vmsg/vmsg.wasm
Nevertheless inside index.js I hit a problem on this code (coming from the vmsg demo)):
handleRecord = () => {
vmsg.record({
wasmURL: require("vmsg.wasm"),
shimURL: "https://unpkg.com/wasm-polyfill.js#0.2.0/wasm-polyfill.js",
}).then(record => {
this.setState({record});
});
};
I get the error message:
remote: ./src/index.js
remote: Cannot find module: 'vmsg.wasm'. Make sure this package is installed.
remote:
remote: You can install this package by running: npm install vmsg.wasm.
I suppose I only need to put the proper import at the top of index.js.
Or modify this line:
wasmURL: require("vmsg.wasm"),
Though I am not sure and what I tried failed. Am I right? If YES, what is the right way to do it?
Or do I really need to run "npm install vmsg.wasm" as mentioned in the message?
.....
After giving it a try, this is actually not a valid solution; running:
npm install vmsg.wasm
is of no use.
Trying to follow this guide: How to Build a Simple React app With Express API but when running
npx create-react-app react-express-app --template typescript
I get this output:
npx: installed 98 in 12.964s
Creating a new React app in /home/aioobe/projects/daily-challenge-5/react-express-app.
error Could not open cafile: ENOENT: no such file or directory, open '/etc/pki/tls/certs/ca-bundle.crt'
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template-typescript...
You appear to be offline.
Falling back to the local Yarn cache.
yarn add v1.22.4
error Could not open cafile: ENOENT: no such file or directory, open '/etc/pki/tls/certs/ca-bundle.crt'
[1/4] Resolving packages...
error Couldn't find any versions for "cra-template-typescript" that matches "latest" in our cache (possible versions are ""). This is usually caused by a missing entry in the lockfile, running Yarn without the --offline flag may help fix this issue.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Aborting installation.
yarnpkg add --exact --offline react react-dom react-scripts cra-template-typescript --cwd /home/aioobe/projects/daily-challenge-5/react-express-app has failed.
Deleting generated file... package.json
Deleting generated file... yarn.lock
Deleting react-express-app/ from /home/aioobe/projects/daily-challenge-5
Done.
Does anyone have any idea of what's going on here?
Did some more googling and someone suggested it was a network issue, so i fiddled with my VPN and it finally worked.
So, if you run into this, check that you have proper network connection working.
I started learning React.js and when I type in the command line npx create-react-app {name of project} it starts downloading the dependencies but at the end I get an error with yargs-parser being a low level vulnerability, I've tried updating the package, deleting the project and creating one again, reinstalling node.js and still doesn't work, besides I've seen in all tutorials that in the initial setup after creating a react project I should have more folders than those that I have, cause I only have the folder: node_modules and the files: package.json, package-lock.json, no public folder and from src I have only the .json files I mentioned earlier, I would appreciate if somebody could help with this problem :/ .
npx create-react-app {project name}outputs:
found 1 low severity vulnerability run "npm audit fix" to fix them, or ""npm audit for details
npm audit outputs:
Low Prototype Pollution
Package yargs-parser
Patched in >=13.1.2 <14.0.0 || >=15.0.1 <16.0.0 || >=18.1.2
Dependency of react-scripts
Path react-scripts > webpack-dev-server > yargs > yargs-parse
More info https://npmjs.com/advisories/1500
After trying reinstalling node, cleaning npm cache, deleting node folders on ProgramFiles, trying creating a project with yarn create react-app , the only thing that worked for me was to install nodejs for Windows x86.
OS: Windows 10 x64