I am trying to install grunt-cli in my pc globally by command
npm install -g grunt-cli
after this I am not getting any error. But when I try to run grunt command I am getting error.
Screen shot has been attached.
Please check Grunt on Windows 8: 'grunt' is not recognized.
You need to correct PATH from environment variable.
Here you have installed grunt but not configured it. You will have to create a Gruntfile.js which is read by grunt and it should have a default task. This default task will be run when you are typing "grunt". And this file should be exactly in the folder from where you are running "grunt" command.
For a kick start go through the following url:
http://www.thegeekstuff.com/2014/08/grunt-introduction/
It gives a very easy and minimized introduction to getting started with grunt avoiding all the complexities which you can explore later once you are comfortable.
Kishore,
It looks like grunt isn't in your path. Try running path=%PATH%;%APPDATA%\npm in your shell.
Related
For example when I run gulp I don't have to do npx gulp.
I can omit the npx and just run gulp
How do I do this for my own package?
I've added mycommand to the package npm bin config, but I still always have to do npx mycommand for it to work.
It depends on your operating system. On a UNIX-based OS (ie. Linux or Mac) you can use the alias command:
$ alias gulp="npx gulp"
For the rest of your terminal session, you can then run:
$ gulp
to run npx gulp. However, whenever you restart your terminal program, you'll lose the alias.
To make the alias permanent, you need to add the alias command to the appropriate start-up file (eg. .bashrc, .profile, etc.) for your OS. Simply copy/paste the exact command you used before, at the end of that file, save, and restart your terminal. You'll have the alias permanently.
Aliases in Windows are also possible, but are a bit trickier; see Aliases in Windows command prompt.
You don't have to use npx gulp for gulp because it is installed globally
So, there's gulp.cmd, gulp.ps1 and gulp starting npx gulp somewhere in PATH, so you can run them from there
this answer is low effort, feel free to edit it
if you install gulp globally:
npm i -g gulp
you will be able to just run gulp
I would avoid answers suggesting global installs (npm install -g). Global installs guarantee that everyone working on a project has their own unique set of tools, and the reason companies end up with huge wiki pages on "how to get the project working locally".
You mention the "bin config", but perhaps you're misunderstanding that one. That's not for specifying commands that your app will use. If you were making a cli application, the bin section in package.json is where you would specify the commands exported by your project. For example, gulp exports the gulp command like:
"bin": {
"gulp": "./bin/gulp.js"
},
Instead, you would add dependencies needed by your application to devDependencies. This ensures that everyone using the project will get the same version of all of the tools, such as gulp, tsc
Using npx is a far better solution because you can add everything the project needs in devDependencies, and npx will use that version. For the common command line tools, an alias such as #machineghost suggests is a better way to go, but to expand on it a bit:
Sometimes, the name of the command is different from the name of the package. In those cases, the alias can use:
alias tsc='npx --package=typescript tsc'
Normally, when running npx, it will prompt to install if there is not a version found in the current project. This is often a good safeguard, because it reminds you to add it to the devDependencies of the project. However, if you really want it to "just work" like a global install, you can add the "yes" flag:
alias command=`npx -y gulp`
This will use the version specified in the current project if present, but install it and run it directly if not.
I have used grunt on this computer before for other projects (4 months ago), and recently wanted to use grunt for a new project. I loaded grunt globally and then locally, but after that typing in $ grunt -v says grunt is not recognized as if it is not loaded, or perhaps the path is wrong? anyone got any ideas?
Update: 5/16/2016, I tried the below suggestion and loaded casper-cli globally and locally, and the grunt command still fails. Additionally, I tried another command 'casperjs' and that one is also failing even though that has worked perfectly for the last year or so. It appears all of my commands are not working anymore, what could possibly cause that?
You have to install the grunt-cli globally to use grunt in the console:
npm install grunt-cli -g
I have installed grunt and grunt-cli globally using sudo npm install -g grunt... commands.
My working folder is `/opt/web', please don't ask why :)
Checking grunt version inside `/opt/web' works:
$ grunt --version
grunt-cli v0.1.13
However, I can't actually run a grunt task from there:
$ grunt
grunt-cli: The grunt command line interface. (v0.1.13)
Fatal error: Unable to find local grunt.
If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project.
If I install grunt locally, it then asks to install all it's dependencies locally (that are already installed globally (!)).
This behavior seems strange to me.
My question is:
Is this a bug or a feature? Is this by design that grunt wants to work with locally installed things only?
This is by design. See the grunt-cli readme.
The cli doesn't do anything except find and run a local copy of grunt.
This means that each project can use a version of grunt that the project specifies and is know/tested to work correctly. Given the number of critical things grunt can do, this compatibility promise is a big deal.
There is also a good blog post on the node site that talks a bit more about module installation locations.
Git is installed and is in the path.
Platform: Red Hat Enterprise Linux 5.8.
>which git
/usr/local/bin/git
Yet bower can't find it:
bower angular#1.0.6 ENOGIT git is not installed or not in the PATH
What is the recommended work-around?
Adding Git to Windows 7/8/8.1 Path
Note: You must have msysgit installed on your machine. Also, the path to my Git installation is "C:\Program Files (x86)\Git". Yours might be different. Please check where yours is before continuing.
Open the Windows Environment Variables/Path Window.
Right-click on My Computer -> Properties
Click Advanced System Settings link from the left side column
Click Environment Variables in the bottom of the window
Then under System Variables look for the path variable and click edit
Add the pwd to Git's binary and cmd at the end of the string like this:
;%PROGRAMFILES(x86)%\Git\bin;%PROGRAMFILES(x86)%\Git\cmd
Now test it out in PowerShell. Type git and see if it recognizes the command.
Source: Adding Git to Windows 7 Path
Just use the Git Bash instead of cmd.
Run the following command at your node.js command prompt where "<git path>" is the path to your git bin folder:
set PATH=%PATH%;<git path>;
So, like this:
set PATH=%PATH%;C:\Program Files\Git\bin;
Or this: (Notice the (x86) )
set PATH=%PATH%;C:\Program Files (x86)\Git\bin;
This will add git to your path variables. Be sure you type it correctly or you could possibly delete your path vars which would be bad.
Make sure you installed Git with the second or third option selected from the list. It will penetrate the Git command to cmd by modifying PATH automatically ;)
I had the same error in Windows. Adding git to the path fixed the issue.
G:\Dropbox\Development\xampp\htdocs.penfolds.git\penfolds-atg-development>bower install
bower bootstrap#~3.0.0 ENOGIT git is not installed or not in the PATH
G:\>PATH
PATH=E:\Program Files\Windows Resource Kits\Tools\;
G:\Dropbox\Development\xampp\htdocs.penfolds.git\penfolds-atg-development>set PATH=%PATH%;E:\Program Files\Git\bin;
G:\Dropbox\Development\xampp\htdocs.penfolds.git\penfolds-atg-development>bower install
bower bootstrap#~3.0.0 not-cached git://github.com/twbs/bootstrap.git#~3.0.0
bower bootstrap#~3.0.0 resolve git://github.com/twbs/bootstrap.git#~3.0.0
I am also getting the same error and the solution is first to check if the Git is installed or not in the system and if not please install it.
After installation, open Git Bash or Git Shell from Windows and go to your project (same way you go in command prompt using "cd path"). Git Shell is installed by default with Github windows installation.
Then run the same bower install command. It will work as expected.
The below screenshot shows the command using Git Shell
On Windows, you can try to set the path at the command prompt:
set PATH=%PATH%;C:\Program Files\Git\bin;
When you ran the git install, you probably didn't choose:
"Use Git from the Windows Command Prompts"
during the installation.
Re-run git install, and choose that option.
You are missing the ENVIRONMENT PATH. Follow these steps:
Search for 'Edit the system environment variables'.
Click on 'Environment Variables'.
In the 'System variables' section, scroll down and click on the variable 'Path'. Click 'Edit'.
Append this text to the end of the 'Variable value'.
;%PROGRAMFILES%\Git\bin;%PROGRAMFILES%\Git\cmd
I also got the same problem from cmd and resolved using the following steps.
First install the https://msysgit.github.io/ (if not alredy installed).
Then set the Git path as suggested by skinneejoe:
set PATH=%PATH%;C:\Program Files\Git\bin;
Or this (notice the (x86)):
set PATH=%PATH%;C:\Program Files (x86)\Git\bin;
In Linux:
if you dont have installed git use:
sudo apt-get update
sudo apt-get install git
with command which git you will know the directory where is and then add in path if it is not in that enviroment variable.
I bumped into this problem on a cPanel CentOS 6 linux machine.
The solution for me was to symlink the cPanel git to /usr/local/bin/git
ln -s /usr/local/cpanel/3rdparty/bin/git /usr/local/bin/git
1.Set the Path of Git in environment variables.
2.From Windows command prompt,
run cd Project\folder\Path\
run the command: bower install
People above already gave solutions for your proplem, I hope so. If someone is facing this issue in 2022 in using docker images, then you should add a command to install git in your image.
For Example you are using alpine image in your Dockerfile. Then it will be something like this :
FROM node:8.3-alpine
# ....... other stuffs .....
RUN apk add git
# ....... other stuffs .....
I solved the problem by install Git Bash from Download Git Bash.
Setting this option 3 when installing the software as shown bellow.
Finally select the project folder by right click using Bash as shown below.
and type
npm install
. It works for me.
npm install from git bash did work for me.
After rebooting PC.
Just use the Git Bash instead of node.js or command prompt
As an Example for installing ReactJS, after opening Git Bash, execute the following command to install react:
bower install --react
I had the same problem and needed to restart the cmd - and the problem goes away.
I just installed git and bower via NPM for a project. It's a first time use.
Then I tried running bower install jQuery for example, I get this specific error:
ENOGIT git is not installed or not in the PATH
Where can I actually define paths and how, and when we say PATHs, what's the main idea?
Also, I really need help with some good resources for learning the concept behind this question or learning NPM usage in general.
I'm using windows 7, 64-bit.
Install msysgit, as stated in the Bower documentation:
To use Bower on Windows, you must install msysgit correctly. Be sure to check the option shown below:
[ ] Use Git bash only
[x] Run Git from the Windows Command Prompt
[ ] Run Git and included Unix tools from the Windows Command Prompt
After the installation has completed, restart CMD. You (and bower) will then be able to run git from the command prompt, which will fix your issue.
Make sure u installed git with 2nd or 3rd option selected from list.
It will penetrate git command to cmd by modifying PATH automatically ;)
Manual method is to add the Git cmd path to your windows PATH environment variable. The Git cmd path will be unique on your machine, and something like:
C:\Users\<YourUserName>\AppData\Local\GitHub\PortableGit_<SomeGuid>\cmd\
From command prompt, add it to your PATH var like so:
path C:\Users\<YourUserName>\AppData\Local\GitHub\PortableGit_<SomeGuid>\cmd\;%PATH%
Install Bower using Git Bash and run bower install jQuery from Git Bash. Git doesn't work from Windows command prompt as CMD is not POSIX compatible.
Forget powershell and command prompt. Use git bash and it works like normal.
Make sure you use the "Git bash" in that directory but not the command terminal of the system:like this
First install git on your pc, if you do not add the path then add it yourself
C:\Program Files\Git\cmd