Why do I get "sh: next: command not found" when running a cloned nextjs app? - next.js

I've cloned a nextjs example repo locally, and tried to run it using npm run dev, but it's not finding "next" as a command?
sh: next: command not found
I googled it, suggestions seemed to be that I should run
npm i -g create-next-app
Which I did, but still get the same error?
How can I resolve this?

For my particular case, I forgot to run npm install in the repo I'd just cloned :D
Once I did that, running npm run dev worked fine and found next.
But I suspect in general if you're trying to run a cloned repo based on npm, and get a similar response, you may simply have forgotten to install your dependencies, like I did.
Note that this can also happen for an existing project if you have some script that removes the node_modules folder as part of a cleanup process (which I do as well)

Related

Something went wrong installing JavaScript dependencies, check your npm logfile or run npm install again manually [duplicate]

I am using react native and Expo. I am unable to build new app because after I use expo init appName it shows the following error.
Heres the full message:
📦 Using npm to install packages. You can pass --yarn to use Yarn instead.
√ Downloaded and extracted project files.
× Something when wrong installing JavaScript dependencies. Check your npm logs. Continuing to initialize the app.
✅ Your project is ready!
To run your project, navigate to the directory and run one of the following npm commands.
- cd Scanner
- npm start # you can open iOS, Android, or web from here, or run them directly with the commands below.
- npm run android
- npm run ios # requires an iOS device or macOS for access to an iOS simulator
- npm run web
I tried multiple times to create a blank project, also tried npm install to install failed/not downloaded libraries and continue after failure but it showed another error:
npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! zlib: unexpected end of file
also tried npm cache verify that showed cache is ok Content verified: 3562 (252580364 bytes).
So, How can I solve this issue?
Problems related to npm installation are very common If you do any mistake in early installation, but is avoided. Learn more about npm tree.
Steps worked for me are :
npm cache clean --force
npm cache verify
npm -g uninstall expo-cli --save
npm install expo-cli --global
expo init app-name
cd app-name
npm start
Always run as administrator if working on Windows and in root directory.
The solutions above didn't work for me but if you use 'npm install' in the directory of the app you get a clue that you shuold try 'npm install --force'
err message
You should have all these files folders and files at the start of the project otherwise not all the dependencies have been installed which is why we were getting the problem.folder structure
After you have added --force to npm install you have all the dependencies installed. Now you can run the app with npm start.
Unfortunately, all the solutions described above didn't work on my machine...
Here is my latest solution for this problem...
This worked 100% on my machine...
Use npm i -g expo-cli
This will automatically add the required packages and also remove the unnecessary ones.
Yes, surely, you don't need to uninstall and re-install it again.
Just follow my steps.
And, you can create your expo project using expo init.
I hope my solution will help you out from this annoying problem....
I just did npm install and it worked for me, but I had do that every time I create a new expo project.
I also encountered this problem, and finally found that it was the problem of react native cli,I installed the latest version of react native cli,Expo is back to normal
This Error is regarding to the git account. expos need a git account to setup react native project
If you are using windows you need to install git in your local PC
after that open your Terminal and type this command
git config --global user.name "your_username"
git config --global user.email "your_email_address#example.com"
after that clone any github project to your local computer. it will ask to login to Github
after all these steps try expo init <projectname>
The simple way to settle that error is by using "expo-cli init app-name" instead of "expo init app-name".
I tried and worked perfectly for me. Hope it will help you guys.
i have faced a similar problem and running yarn set version 1.22.1 fix it
Run the Command Prompt as an administrator. And run the following command:
npx create-expo-app AwesomeProject

NextJS stuck at compiling

All of my next apps are getting stuck at event - compiled successfully when I try and run them using yarn dev. Everything from existing apps I've used before to brand new apps I literally make just for trying this fresh.
I've tried deleting node_modules and yarn.lock, running yarn again, then running yarn dev. No dice. I also updated node js to latest and tried a few iterations of the above, including some with a 'yarn build` step to see if that did anything. No luck.
Assuming it's some kind of machine config that got messed up, but I can't for the life of me figure out what it is. Ideas?
replace with it in package.json
“dev”: “next dev -p 1234",

mup deploy works but image won't start

I'm deploying my Meteor app with mup from a Windows 10 box to a Digital Ocean VPS. Latest version of mup, latest version of meteor, app runs fine on Windows and the app deployed and ran fine before adding node-uber NPM. I see the following error in the logs when the app tries to start:
npm ERR! enoent ENOENT: no such file or directory, chmod '/bundle/bundle/programs/server/npm/node_modules/node-uber/node_modules/sshpk/bin\sshpk-conv'
Obviously the problem is with the backslash in the filename, but not sure where that is coming from or how to fix it. It isn't referenced in the package.json for node-uber. I've tried editting the package.json for sshpk on the Windows side, but that doesn't make any difference. I can't edit the file in the Docker container because the container keeps restarting and kicking me out.
Anyone have any suggestions on how to fix this, perferably permanently so I don't have to jump through hoops every time I deploy?
Actually manually editting the package.json file does solve the problem. Turns out I have multiple copies of sshpk installed because the parent NPMs are specifying specific versions as being required.
So the "fix" for this problem is the edit the "bin" section of the sshpk package.json file to flip the "\" to "/", save and rerun mup deploy.
Sigh...

Why is Visual Studio looking for my gulpfile in the wrong folder?

Backstory
I've been trying to set up a project in Visual Studio, which uses GulpJS to compile Sass. I was told that VS should automatically recognize the package.json inside a project and run npm install, but I had to do that manually through a command line. Even then, when I opened Task Runner Explorer, it says that there are (No tasks found). My coworker and I looked up solutions that worked for other people, many of which reported having success after restarting VS, clearing some cached data, or reinstalling the node modules; however none of those worked for me. Here are some solutions I've attempted:
Visual Studio 2015 RC Gulp task runner not detecting tasks (All Answers)
https://stackoverflow.com/a/37437209/6425704
Basically the entire first page of Google for "visual studio gulp no tasks found"
The Problem
After some digging, I came across the Package Manager Console and decided that maybe I can run gulp through that instead of opening a separate CMD window. However, when I did, I got the following:
[11:27:43] Local gulp not found in C:\
[11:27:43] Try running: npm install gulp
My immediate thought was that I might need to reinstall the dependencies, so I ran npm install and got this output:
npm : npm WARN enoent ENOENT: no such file or directory, open 'C:\package.json'
At line:1 char:1
+ npm install
+ ~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (npm WARN enoent...:\package.json':String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm
WARN
!invalid#1 No license field.
This is when I noticed that it is looking for C:\package.json instead of the one inside my Project directory. However, when I ran ls, it clearly shows that it's inside the Solution root, at C:\Dev\solution-name. I tried navigating to the specific Project, using cd Presentation\Nop.Web, but I still get the result of it looking in the C:\ root. Can anyone explain why this is happening and how I can fix it?
I finally figured it out (one more day, and I would've offered a bounty for this question), and it's not a problem with VS. Back when I first started using this specific computer and was still using Windows' default Command Prompt, I didn't like it starting in %USERPROFILE% by default. So I looked for a way change the default and stumbled upon a registry "hack" which essentially runs cd C:/ on cmd.exe startup. However, it turns out that this causes other command line tools, including Powershell and VS's Package Manager to run that command.
If anyone else is experiencing this issue (which, due to the nature of this situation, I doubt anyone has), you can try following these steps:
Open up Registry Editor. I did it by using the Windows Run tool (Win + R) and typing regedit.
Navigate to HKEY_CURRENT_USER > SOFTWARE > Microsoft > Command Processor.
Remove AutoRun (or change its value to something that won't interfere with your workflow).
More info here.
Original Registry Tutorial (Note that if I had scrolled down a bit more, I might have avoided this situation.)

Npm module "grunt-contrib-imagemin" not found, Is it installed?

I run into this error, when I try to do build a project with "grunt build".
There seems to be no problem when I test the project by doing "grunt server".
The project has been scaffolded and managed with: yeoman/grunt/bower. In Windows.
Everything went well and then a week ago or so it started doing this. I can't build projects no more.
When I try to install the module doing:
npm install grunt-contrib-imagemin
It can never install it, get the following "weird" error.
Any hints please?
Ok I found a way to solve this:
In your package.json, add "jpegtran-bin": "0.2.0" before the reference to imagemin
Delete the node_modules folder in your project, and run "npm install" and "bower install" again
There seem to be an issue with the jpegtran's latest version.
!! - Please note this is just a workarround waiting for the bugfix.
Like the program suggests, you need to install the npm module.
npm i --save-dev grunt-contrib-imagemin
Considering you're on Windows you might want to take a look at the project's GitHub repo for additional installation instructions.
There's an issue with a package contrib-imagemin references that prevents it from properly installing on Windows.
GitHub issue on grunt-contrib-imagemin: https://github.com/gruntjs/grunt-contrib-imagemin/issues/109
GitHub pull request on the offending library: https://github.com/yeoman/node-jpegtran-bin/pull/38
For now, you can manually specify "jpegtran-bin": "0.2.0" in your package.json and it should function as a workaround. If it's a pain point for you, go comment on that pull request and perhaps it'll convince the project maintainer to actually take a look and comment as well.
I had the same problem with 0.3.0 version, but once I updated to 0.4.0 the problem was solved. Check your package.json. Hope that helps!
"grunt-contrib-imagemin": "~0.4.0",
As of May 2015 I solved this by deleting node_modules and running npm install.
I am using windows, I was getting same error.
So I edited the Environmental Variables.
Just add: C:\Ruby200-x64\bin to your PATH variable and restart node prompt.
The imagemin install seems to not run correctly when called by grunt-contrib-imagemin. I just do
cd ./node_modules/grunt-contrib-imagemin/node_modules/imagemin
npm install
And then it's fine.
On Ubuntu 14.04.3 LTS, package.json containing:
"grunt-contrib-imagemin": "~0.4.0",
I had to reinstall Grunt (but the jpegtran-bin workaround, or just removing node_modules and running npm install wasn't enough, I needed the following (with sudo):
rm -rf node_modules/
sudo npm update -g npm
sudo npm install -g grunt-cli

Resources