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

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.

Related

NPM Packages (with CLI) installed globally return command not found

I've had this happen twice to me before. The first time I assumed it was an error with NPM, so I uninstalled Node & NPM and didn't use the package that was giving me an error.
I did a fresh install & began working on another project. I'd installed the package (and the version of it with cli). The command line command worked during the terminal session during which i'd installed it both globally and in my project. However in other terminal tabs and in new terminal sessions the command returns command not found.
when I run npm root i receive:
/Users/MYUSERNAME/node_modules
and when I run npm root -g, i receive:
/Users/MYUSERNAME/.npm-global/lib/node_modules
For what it's worth the two packages I've tried this with are mjml (and mjml-cli) and gulp (and gulp-cli). I've uninstalled both and reinstalled again from my root directory using the -g flag and that doesn't seem to have changed anything.
I appear to have missed this somewhere in the googling I did before asking this question.
Apparently I had been accidentally installing global packages in my local folder (/Users/YOURUSERNAME/node_modules).
Running npm config set prefix /usr/local fixed the issue.

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.

'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.

Node.js/Windows error: ENOENT, stat 'C:\Users\RT\AppData\Roaming\npm'

I have Windows 7 32-bit. I installed the latest Node.js 32 bit.
When I try to run the command npm install jquery, I receive the error:
Error: ENOENT, stat 'C:\Users\RT\AppData\Roaming\npm
How does one resolve it?
Manually creating a folder named 'npm' in the displayed path fixed the problem.
More information can be found on Troubleshooting page
I ran into the same problem while installing a package via npm.
After creating the npm folder manually in C:\Users\UserName\AppData\Roaming\ that particular error was gone, but it gave similar multiple errors as it tried to create additional directories in the npm folder and failed. The issue was resolved after running the command prompt as an administrator.
This can also be fixed by installing a node package manually.
npm install npm -g
The process of doing that will setup all the required directories.
I recommend setting an alternative location for your npm modules.
npm config set prefix C:\Dev\npm-repository\npm --global
npm config set cache C:\Dev\npm-repository\npm-cache --global
Of course you can set the location to wherever best suits.
This has worked well for me and gets around any permissions issues that you may encounter.
You can go to the Start Menu and search the Node.js icon and open the shell and then install anything with
install <packagename> -g
Install a stable version instead of the latest one, I have downgrade my version to node-v0.10.29-x86.msi from 'node-v0.10.33-x86.msi' and it is working well for me!
http://blog.nodejs.org/2014/06/16/node-v0-10-29-stable/
I needed a package from github that was written in typscript. I did a git pull of the most recent version from the master branch into the root of my main project. I then went into the directory and did an npm install so that the gulp commands would work that generates ES5 modules. Anyway, to make the long story short, my build process was trying to build files from this new folder so I had to move it out of my root. This was causing these same errors.

How to install and run lessc on top of node.js and Windows?

Hi I am learning LESS and I would like to install lessc on my Windows 7.
Following this tutorial http://verekia.com/less-css/dont-read-less-css-tutorial-highly-addictive
The first step is I dowloaded and installed node.js (node-v0.10.5-x64.msi).
Then in a console, I ran
npm install less -g
I got the following:
npm http GET https://registry.npmjs.org/less
npm http 304 https://registry.npmjs.org/less
npm http GET https://registry.npmjs.org/ycssmin
npm http 304 https://registry.npmjs.org/ycssmin
C:\Users\Me\AppData\Roaming\npm\lessc -> C:\Users\Me\AppData\Roaming\npm\node_modules\less\bin\lessc
less#1.3.3 C:\Users\Me\AppData\Roaming\npm\node_modules\less
+-- ycssmin#1.0.1
Then I ran the following in the same console:
lessc style.less > style.css
But I got
'lessc' is not recognized as an internal or external command, operable program or batch file.
I am not sure where I got wrong. I googled but it seems there is too much stuff, not sure which one is right. Did many tests without any success.
Could someone tell me how to do it or give me a pointer to some place with detailed and latest install info for Windows?
In a console, run the following:
node C:\Users\Me\AppData\Roaming\npm\node_modules\less\bin\lessc style.less > style.css
style.less must be in the console's directory.
step 1: npm install less -g
step 2: npm i less --save-dev
to get lessc working you have to add
C:\Users\Me\AppData\Roaming\npm
to the path
I guess you could add the bin folder in system properties -> advanced ->environment variables and append the whole path to the bin folder by edited the Path variable.
If you just installed node.js, the windows PATH variable won't be updated within any running CMD windows. Try closing CMD and reopening it!
I fixed this issue by using Node Version Manager (nvm) to install and use the latest version of Node.js
nvm install latest
nvm use 12.4.0
After that I navigated to my project folder and typed:
npm install less -g and then
npm i less --save-dev
Finally I typed lessc less/index.less css/index.css to compile my less.
If you are using windows, don't forget to open the command line console as an administrator.
After spending around number of hours hunting around to compile less files, I got very simple answer:
download node-v0.10.26-x64.msi for windows users -> install it -> then
go to any folder(in command prompt) where *.less files are located and run the command
"lessc styles.lsss > styles.css". (Example: in command prompt, less is my less folder where *.less files exist)
D:\less>lessc styles.less > styles.css
now you will get styles.css files created automatically. Open and see styles.css file
Well, you must have NodeJS installed on your machine, use this link to download and install it.
Once installed make sure to restart your machine.
Then check whether it is properly installed by running "node -v" and "npm -v" in CMD.
Once that is done run "npm install less -g" and you are ready to compile your less files.
Just go into the directory where your files are and run "lessc style.less style.css"
More can be found on this link.

Resources