How do I run Next.js app after cloning repository - reactjs

I created a Next.js app using npx create-next-app#latest, pushed the new app to a GitHub repository, then cloned the repository into a new directory. When I tried to run the app using npm run dev, I got the following output:
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mini-warehouse#0.1.0 dev: `next dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mini-warehouse#0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
I was expecting the development server to start. How can I run my app?

npm WARN Local package.json exists, but node_modules missing, did you mean to install?
run : npm install
NOTE : you have always to install node_modules after coloning a repo. because when you push inside a repo the .gitignore file by default ignores node_modules folder because of its size so you should install it by running npm install

the last line from you error stack is telling you the problem
Your projet has an package.json but you didn't install your dependencies
You should install before trying to run you project
running npm install and then npm run dev
https://docs.npmjs.com/cli/v9/configuring-npm/package-json
if you want to know more about package.json

Related

Vercel React.js Deployment: Cannot find module: 'firebase'. Make sure this package is installed

I deployed a react app to Vercel that uses firebase. The build exits with status code 1.
I have installed firebase using: "npm install firebase" and it is running well on the local environment. What would be the possible error?
Creating an optimized production build...
Failed to compile.
./src/firebase.js
Cannot find module: 'firebase'. Make sure this package is installed.
You can install this package by running: npm install firebase.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! neozon#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the appname#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! /vercel/.npm/_logs/2022-01-11T18_49_38_751Z-debug.log
Error: Command "npm run build" exited with 1
My guess is that the firebase package isn't installed on the server (unlike on your local environment), which most likely reads the dependencies from the package.json.
To add firebase to your package.json on your local system, run:
npm install firebase --save

Create a react app and use a npm start command but it is not working

I am a newbie in react js.When i want to create-react-app-todos-list it is creating but not displaying success message.
As a result when i use npm start command it is displaying error.So please help me to fix this error.
//When i am using create-react-app todos-list it is displaying the following in vscode
npx create-react-app todos-list
Creating a new React app in D:\react\todos-list.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1357 packages in 1m
166 packages are looking for funding
run `npm fund` for details
//When i am using npm start command it is displaying as like this
PS D:\react> npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path D:\react/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'D:\react\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\shaik\AppData\Local\npm-cache\_logs\2022-01-14T14_29_47_642Z-debug.log
PS D:\react>
**Solutions I tried
For create-react-app**
npm uninstall -g create-react-app && npm i -g npm#latest && npm cache clean -f
and SKIP_PREFLIGHT_CHECK=true
You are not inside todos-list directory: PS D:\react>
Type: cd todos-list then npm start
When you create react app with npx create-react-app you have option to name your project like what you are done npx create-react-app todos-list and another option which is to create the app in the current directory npx create-react-app .
The problem in your case comes from that you named your project and now you have to explicitly navigate to the dir of the project because the package.json is in that dir. The package.json is essential because it contains all the necesary scripts to run your app.
If you are on the same console you need to just type:
cd todos-list
and then:
npm start

I'm having a hard time running a react command

I just updated my npm and got rid of some useless packages, but for some reason, I still am running into some weirdness when trying to run this command
kalebamarante$ npm init create-react-app kalebcryptoexchange-app
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/create-create-react-app - Not found
npm ERR! 404
npm ERR! 404 'create-create-react-app#latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/kalebamarante/.npm/_logs/2021-03-09T00_18_58_939Z-debug.log
KALEBS-MacBook-Pro:~ kalebamarante$ npx create-react-app kalebcryptoexchange-app
You are running `create-react-app` 4.0.1, which is behind the latest release (4.0.3).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
npm ERR! code 1
npm ERR! path /Users/kalebamarante
npm ERR! command failed
npm ERR! command sh -c create-react-app kalebcryptoexchange-app
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/kalebamarante/.npm/_logs/2021-03-09T00_20_01_995Z-debug.log
KALEBS-MacBook-Pro:~ kalebamarante$ sh -c create-react-app kalebcryptoexchange-app
kalebcryptoexchange-app: create-react-app: command not found
you should try npx instead of npm init.
npx create-react-app kalebcryptoexchange-app.
You should use npx instead of npm.
npx create-react-app your-app
Now why is that?
When you are using npm command it will get the node packages for you. i.e. You may have installed the package called 'create-react-app' globally using npm. Now to execute that package you have to use npx command.
Your error log shows this line,
npm ERR! 404 'create-create-react-app#latest' is not in the npm registry.
because you are trying to fetch a package instead of creating it using create-react-app.
In short, npm downloads the packages, npx execute a package.

Receive error when deploy to GitHub pages

I'm deploy react app to git hub pages and receive error. File sizes after gzip:
68.67 KB build\static\js\2.c2c334ae.chunk.js
2.98 KB build\static\js\main.8a72b1a2.chunk.js
774 B build\static\js\runtime~main.8f8a00a4.js
The project was built assuming it is hosted at /sort-customers-list/.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
To publish it at https://sejob.github.io/sort-customers-list,
run: npm run deploy
Find out more about deployment here:
sort-customers-list#0.1.0 deploy
C:\Users\SeJo\Documents\Code\DEV_HW\sort-customers-list
gh-pages -d build
The "file" argument must be of type string. Received type undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sort-customers-list#0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sort-customers-list#0.1.0 deploy 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\SeJo\AppData\Roaming\npm-cache\_logs\2019-08-01T12_09_52_445Z-debug.log
The problem occurs in the new version of GitHub pages. Just use this command to install the previous version of GitHub pages:
npm install gh-pages#2.0.1
Hope it will help!
I also had this same problem on a fresh install of create-react-app. I have no idea what the problem was, but I did the following:
Downgrade gh-pages from 2.1.0 to 2.0.1
Instead of running npm run deploy, manually run npm run build then gh-pages -d build from the commandline.
At first, I'd get the same error in the commandline, even after checking that the version was downgraded to 2.0.1, but for some reason it worked after manually creating the gh-pages branch and pushing some files into it. As of now, npm run deploy throws the error but at least gh-pages -d build from the console works.
INSTALL/REINSTALL GIT
Update NPM
Reopen EDITOR
this solved my problem
use version 2.0.1
npm i gh-pages#2.0.1

I just cloned a react app to my local computer from github, but when I go to run an npm start on it, I get this error:

I just cloned a react app to my local computer from GitHub, and I set npm install but when I go to run an npm start on it, I get this error:
C:\Users\NOUREDDINE\Desktop\Redux>npm start
npm ERR! path C:\Users\NOUREDDINE\Desktop\Redux\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\NOUREDDINE\Desktop\Redux\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\NOUREDDINE\AppData\Roaming\npm-cache\_logs\2019-06-06T21_34_57_558Z-debug.logand
First, you need to go to that folder where package.json resides and open cmd by pressing SHIFT+ right click on that folder(please check path, it should be correct), then do npm install, after that do npm start.
If it's worked fine then good and if you already installed the dependency then do the following things:
Delete Node_modules and package-lock.json file
clear cache (npm cache clean --force) or by going to these
folders
c:/users/username/AppData/Roaming/npm-cache and c:/users/username/AppData/Roaming/npm
then do npm install again
that might resolve your issue.
When you clone from the repo it comes with pakage.json which lists all of the dependencies and their respective versions, that are utilized by the app. It doesn't however include these dependencies. In order to run the app you need to navigate to the directory that houses the package.json file in the console and run "npm install". this will create the node_modules directory and download all of the necessary packages. then you can run "npm start".

Resources