Grunt installation in windows - windows

I am trying to install grunt in my system windows 7. I have downloaded grunt from github. When running grunt command its giving unrecognised command. Can anyone help me out in this?

You can install grunt globally via npm (downloading it from here https://nodejs.org/download/). Probably you will need to update your environmental variables (by adding '%USERPROFILE%\AppData\Roaming\npm' to $PATH) or simply restart your PC.
Then you should be able to run npm install -g grunt-cli from your PowerShell or Command Line. When the npm installation is ready you should have access to grunt command.

Related

Do I have to install grunt locally or is it just best practice ...?

or neither.
I installed both grunt-cli and grunt globally as such
inst_grunt(){
# installs the grung-cli to
# /usr/local/lib/node_modules/grunt-cli
sudo npm install -g grunt-cli
# installs grunt based upon the package.json file to
# /usr/local/lib/node_modules/Grunt
sudo npm install -g
}
I thought I could simply run
grunt --gruntfile /Users/a/root/config/Gruntfile.js watch
as stated here:
How do I run grunt from a different folder than my root project
but alas I get this error:
as-MacBook-Air:config a$ grunt --gruntfile
/Users/a/root/config/Gruntfile.js 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. For more
information about installing and configuring grunt, please see the
Getting Started guide:
http://gruntjs.com/getting-started
The grunt file is there so I'm assuming it is looking for a local grunt installation.
You do have to install it locally in order to call functions on it within the gruntfile.
This way your project can specify what version of Grunt should be used (edit) in your package.json file.

I Installed npm But Cannot Install DocPad

Obviously I need to download DocPad (file(s)) before I can do an npm install, but it simply isn't clear to me what to download, etc. I know the file(s) I need are on GitHub, but I don't have the background to understand what I'm looking at. Can you give me, or point me to, a "Download DocPad for Dummies" instructions? Thank you.
To extend on #sindis's comment
When you install Node, you will also install npm, which serves as the node package manager.
npm allows you to install packages globally using the -g flag, which installs a package that has been published to npm (such as DocPad) to wherever the npm global installation directory is, and make DocPad's command line tools available to you.
So by installing DocPad with npm install -g docpad#6.78 (6.78 is the version of DocPad that the command above wishes to install) we will install DocPad to the global npm installation directory, which makes the command line tool docpad available for your use.
I've updated the DocPad installation guide to be a bit clearer about this, suggestions welcome.
The installation of DocPad is all controlled by NPM. So once that is installed, all you should need to do to install DocPad is run the npm command, as others have said, npm install docpad -g.
Now, the gotcha in windows is that you might need to execute this command with elevated rights - ie Administrator. Windows doesn't like you installing programs in its root program directory.

Can't build a Web Project in TeamCity

I am using TeamCity as my CI server(mac).I am trying to build a web project. When I use grunt serve or grunt buildproduction after changing directory to the cloned folder,it's working perfectly fine.But when I do this via TeamCity server it is giving an error You need to have Ruby and Compass installed and in your system PATH for this task to work and gets aborted due to warnings. Ruby and Compass is already installed in the server.Please help me on this.
rm -rf $(pwd)/node_modules/*
rm -rf $(pwd)/bower_components/*
npm cache clear
npm install
npm install bower
npm install grunt-ftp-push --save-dev
bower install
grunt buildproduction
This is the Command Line buildstep which I used in Teamcity..
I would say you probably use a different user or the shell environment is different (interactive vs non-interactive) when you run these commands manually and when it runs through TC it can't find those packages in the environment/PATH

'gulp' is not recognized

I'm completely new to Gulp but I wanted to try it out. Due to restrictions/admin rights on my desktop and moving about a lot, I need things portable, and so am currently running everything I need off a stick.
I've browsed similar posts but none of the solutions seemed to solve the problem I'm having.
I used the following commands in cmd with Ruby to install gulp -
npm install -g gulp
and then
npm install --save-dev gulp
I'm seeing the folders and files, but when I run gulp -v in cmd I get the following:
" 'gulp' is not recognized as an internal or external command, operable program or batch file."
I'm not sure if this is a problem related to the fact I don't have admin rights for this computer or not. Any help so I can troubleshoot further would be much appreciated!
E:\xampp\htdocs\wordpress>PATH
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32
\WindowsPowerShell\v1.0\;C:\Program Files\nodejs\;C:\RailsInstaller\Git\cmd;C:\R
ailsInstaller\Ruby1.9.3\bin
Thanks
My Full Response
Solution
Re-download nodejs
npm install -g gulp
gulp -version
I had the same problem when I installed gulp, I was not able to run gulp in command line. I was getting the following error:
'gulp' is not recognized as an internal or external command,
operable program or batch file.
After doing some re-search I found that I needed to update the Path variable.
Following is the command you can run in command line to add the path to the system path variable.
C:\> PATH=%PATH%;C:\Users\**<username>**\AppData\Roaming\npm
Using VS2017, Net CORE 1.1 I received this error.
I ran the following in a command window at the root of my project:
cmd.exe /c gulp --tasks-simple
This showed me the real error in a stack trace: there was a typo in my gulpfile.js.
So for me the problem was a simple typo and had nothing to do with gulp, npm or installation.
Seems that you didn't configured the /bin folder of your node installation in the PATH variable, however in windows it should be done automatically. The PATH in your question refers to C:\Program Files\nodejs. You can add the environment variable manually or download the latest version and try again.
For those using linux, (if downloaded the Linux Binaries (.tar.xz)) please add, in your home (~/.bashrc), the export of node's bin folder, like:
export PATH=$PATH:/opt/node/bin
1- Check Is NPM Global installer installed the gulp or other package what you looking for
the default path is "C:\Users\YOUR_USER\AppData\Roaming\npm"
If the gulp executable on there you have installed it globally. If not install it globally. Like above right:
npm install -g gulp
2- Add it to windows environment system variables like that to working with it on your local IDE
NODE_PATH %AppData%\Roaming\npm\node_modules
GULP_PATH %AppData%\AppData\Roaming\npm
NPM_PATH %AppData%\AppData\Roaming\npm <- one of them
If someone is having this issue with an npm script that uses gulp, and with gulp as a dev dependency in your package.json, you shouldn't need to install gulp globally, I fixed it by doing a clean install.
npm ci
It sounds like theres some information missing, and while Im a bit confused about the 'commands in cmd with Ruby' this might set you down the right path.
After you install Gulp globally, as you did; npm install -g gulp, you want to cd into your project root and npm install gulp --save-dev. This is all outlined in this article, which is recommended alongside some other getting started articles by Gulp.

Grunt installed but not working - "Command not found" on Mavericks

I'm trying to use grunt with sass and have been following these guides:
http://gruntjs.com/getting-started
http://benfrain.com/lightning-fast-sass-compiling-with-libsass-node-sass-and-grunt-sass/
http://www.hongkiat.com/blog/grunt-command-not-found/
I've:
Intsalled node.js
Installed the command-line version of grunt: sudo npm install -g grunt -cli
Added the path from the grunt installer to my bash profile: export PATH=/usr/local/lib/node_modules/grunt/bin:$PATH
Made the profile an executable: source ~/.bash_profile
Setup package.json and Gruntfile.js files in my project root
Installed grunt into the project: cd /path/to/project/root/ and sudo npm install
But when I try to run grunt I see: command not found
It's the same if I run: grunt --version
I wasn't sure if the bash path needs /bin on the end as per the blog posted above but have tried it both ways:
/usr/local/lib/node_modules/grunt/ and /usr/local/lib/node_modules/grunt/bin/
I've also run the grunt installer several times but didn't see any errors so am positive it's installed - can anyone see what I'm doing wrong? I'm running OSX mavericks incase this is the issue.
Any pointers in the right direction would be much appreciated.
Cheers
You have a typo in your command. The package is named grunt-cli without the space.
Update the command to:
sudo npm install -g grunt-cli
And all should work as expected.
Hope this solution also might be helpful to someone. In my case it was a bit trickier.
In command line type the following command
npm install grunt-cli -g
This will show you the location where the grun client is installed:
Copy this location and paste it into a file browser. Was this in my case.
C:\Users\zkhaymed\AppData\Roaming\npm\node_modules\grunt-cli\bin
This will open you the location of a grunt file.
Click on the address line of the location and copy it as a text clicking on the right mouse button.
Now go to the Advanced properties of the system at control panel, and paste this address into a System variables and user variables without deleting the other variables.
I was having a very similar issue, hopefully this helps.
1) You want to check where node and npm are actually installed. If you used a package manager, such as Homebrew or MacPorts, there may be an issue with the location. Just use the downloadable installer from node.js website. Make sure to use the current version, not the long term support (LTS). The installer will install node and npm in /usr/local/bin, which should already be in your PATH. If you already have node/npm installed you can use which node and which npm to see where they are currently located. You should see /usr/local/bin/node and /usr/local/bin/npm, respectively. You will need to update npm after installing with npm update -g npm. This may require sudo.
2) Once node and npm are correctly installed/updated go to the project's root directory (where you have the Gruntfile.js and package.json) and install Grunt using npm install grunt --save-dev. Remember that Grunt After doing so you should see a new folder called node_modules.
3) Make sure to do the previous step before installing the CLI. You can use Grunt's getting started documentation to help guide you the rest of the way. Just be aware that the instructions for installing Grunt are further down the page than installing the CLI, which makes it somewhat confusing. When Grunt and Grunt-CLI are installed run npm install and run grunt in the command line to execute your Gruntfile.js.
You should now be able to see the versions installed. Note that if you are outside of a project's root directory you will not see a version of Grunt but you will see the Grunt-CLI version. This is because the CLI was installed globally (used from any directory/subdirectory) but Grunt is installed on a per-project basis.
Hopefully this helps!
I just ran into this scenario as well. The following worked for me:
Try deleting C:/Users/{username}/AppData/Roaming/npm and C:/Users/{username}/AppData/Roaming/npm-cache (if it exists) and reinstalling global npm modules.
Source: https://github.com/nodejs/node/issues/29287
I had to add this to the PATH (on a Mac after brew install node ):
export NPM_HOME=/usr/local/Cellar/node/6.3.1/libexec/npm
The npm install was not effective, no matter what args I passed to it.

Resources