Why does Grunt not add itself to the shell? - macos

I have a problem installing grunt. All the documentation, and blog post tutorials, say that running:
npm install -g grunt
will then allow you to run grunt commands from the terminal.
I have a situation where grunt appears to install with no errors, but typing the command grunt in the terminal still gives:
-bash: grunt: command not found
What could I be doing wrong? And where could I find grunt to add it to my BASH profile manually?

Since Grunt version 0.4 (which was released 1 or 2 weeks ago) you need to install the grunt command line tool globally (if needed, use sudo before the command):
npm install -g grunt-cli
In your project location you then install the latest grunt version:
npm install grunt --save-dev
Option --save-dev will save the npm config in your package.json file, which makes it easier to install or reinstall the dependencies (using just npm install).

Try running the install with the verbose flag:
npm install -g grunt --verbose
You can see where it is being installed (something like /usr/local/share/npm/bin/grunt). Then check your path:
echo $PATH
If the path does not contain the install bin location, modify the path in your bash profile to include the location of the bin directory, then try grunt again in a fresh terminal.
UPDATE: Grunt 0.4 altered installation process. For 0.4 installs, see answer from asgoth below.

It seems that grunt in the current version 0.4.0 does not install a bin command. The last 0.3.x version is 0.3.17, which supports a bin command. To run grunt from the command line, you will want to install the grunt command line grunt-cli:
npm install -g grunt-cli --verbose

I had installed node using Homebrew and this was my solution:
set config for -g (GLOBAL) install directory directory: npm config
set prefix /Users/YOURNAME/.node/
make sure to edit PATH: sudo nano ~/.profile
add to path: export PATH=“/Users/YOURNAME/.node/bin:”$PATH
then update source: source ~/.profile
Following these steps will allow any packages installed using npm install -g somePKG to be placed in the correct location regardless of your current working directory. And by updating your $PATH correctly command line functions will work.
Information based on:
Fixing npm permissions - bit.ly/1CmIyqx

Related

Why SCSS compile error in atom?

I need help! I installed sass-autocompile in Atom. Created .scss file. But I have error when I want to compile it.
The problem is that node-sass is not installed in your system, you need to install (globally, so any application or command line execution could reference it without the full path to the binary file) it by running the following command:
npm install -g node-sass
Read more about installing node packages globally here.
Hope it helps.
Try to install node-sass globally. npm node sass
Install:
$ npm install -g node-sass
Check in command line:
$ node-sass -v

Could not execute command lessc' while running odoo (any version) in eclipse mac

After a thorough analysis of 'Could not execute command lessc' i've successfully ran odoo (any version) on my command line with python virtual env. Am doing this to run odoo in command line
$ . {PATH_TO_VIRTUAL_ENV}/bin/activate (Running the script in the current shell)
$ cd {PATH_TO_ODOO_SOURCE}
$ ./odoo.py -c setup.cfg
And the above runs with proper UI.
Now when trying to run the same from eclipse throws me 'Could not execute command lessc'. I did the below to run code from eclipse
Installed pydev plugin in eclipse Mars
Configured Python interpreter (Given the virtual env python path here. i.e {PATH_TO_VIRTUAL_ENV}/bin/python)
Setup odoo source
Specified the new python interpreter on the project properties -> python interpretor
Created a new Run Configuration to run the source with the custom setup file and with the new interpretor
Kindly throw me light on places where i miss. Also i've gone through links on setting up python virtual env in eclipse. They all say the same thing still this lessc dependency is somehow not linked. Please comment if you require more info to identify the error. Thanks for your help! :)
FYI am using mac.
Update
For Shikhar (based on his answer)
This problem is related to your bad configuration of Nodejs and less on system.
Use commands below to resolve this -
wget -qO- https://deb.nodesource.com/setup | sudo bash -
then
brew install node
and finally
sudo npm install -g less less-plugin-clean-css
This will resolve the lessc command issue.
try this
sudo apt-get install node-clean-css
sudo apt-get install node-less
The solution:
sudo apt-get install node-clean-css
sudo apt-get install node-less
may work for Global system installation but if you are working within a virtualenv you may try this.
If somebody had the issue inside PyCharm wich was my case and nothing else works...
I leave my solution here:
First: I tried to check if node and npm exist inside my virtualenv: node -v and npm -v, not any of them... Second: I was using virtualenv, also when I ask inside my virtualenv with: which lessc . I didn't receive any response neither, so... I keep googling and found this post: How to install lessc and nodejs in a Python virtualenv?
In any case this was what I did on my virtualenv and the problem was solved:
MYVIRTUALENV/bin/activate # switch to my Python virtualenv first
pip3.7 install nodeenv # install nodeenv nodeenv was installed, in case you are using python 2.x use pip instead pip3
nodeenv --python-virtualenv # Use current python virtualenv
npm install -g less # install lessc in the virtualenv
npm install -g less-plugin-clean-css # also install this less-plugin...
then if I check with node -v and npm -v I get a proper response...
also get good response on: which lessc
After that no more nightmare with lessc execution in pycharm

error: -bash: grunt: command not found

bit of a macosx noob , trying to install grunt on my machine. I tried:
npm install grunt
It look like the files are downloaded properly but still getting the error.
When I do echo $PATH it does not look that the path is pointing to grunt. Do I have to install it from a certain directory? How can I fix this?
Edit
After I run :
npm install -g grunt-cli
This happens:
You have to do sudo npm install -g grunt-cli, then you can use grunt in your terminal

Command error running installed npm modules

Hi guys could you help me? i've installed the latest version of node.js and installed cordova and ionic framework the problem starts is when i'm trying to run the ionic command, the console throw me the following message:
MacBook-Pro-de-Diego:~ diegochavez$ ionic start myApp
-bash: ionic: command not found
So then i looked for the root of my npm modules
MacBook-Pro-de-Diego:~ diegochavez$ npm root
/Users/diegochavez/node_modules
if you guys know something to fix this? Thanks in advance
First check if ionic is installed at path like /usr/local/lib/node_modules/ionic/bin/ionic. If it is there, you need to check the npm default global path.
Run command npm config get prefix to check the default path, it should be /usr/local. If it is not /usr/local, run command npm config set prefix /usr/local to set it. And then install again. Also see this answer
I having issue while running - sudo npm install -g gulp ionic with below version of node installed
node -v v0.10.15
npm -v 1.3.5
Error went way after I update node to latest version v0.10.26
The error you are getting is because ionic was not installed successfully. Trying updating node and run command as mentioned sudo npm install -g gulp ionic
Check where your npm folder is located. If your npm folder is located in $Home..then type this:
export PATH="$HOME/npm/bin:$PATH"
You need to run sudo npm install -g ionic from the command line.

fine-uploader example traditional build

So, I'm trying to evaluate fine-uploader. I decided to go to the download page, but it wants you to purchase a license, but I don't want to do that until after I've evaluated it. So, I went to github and downloaded the master zip for it and unzipped. My question is now what? The so-called "step-by-step" are not step-by-step. Am I supposed to build something? The documentation states I just need to include one file....which file? In the demos, for traditional use, i see it includes fineuploader-{VERSION}.js, but I see no file that even starts with "fineuploader" in the subdirectory of "client/js/*".
Am I just missing the documentation for this completely?
Thanks!
Following Bjørn Børresen's answer, the official documentation (which is severely lacking) and some troubleshooting, I was successfull on Ubuntu 13.10 with the following commands:
sudo apt-get install npm git
sudo npm install -g npm
sudo npm install -g grunt-cli
sudo npm install -g bower
git clone https://github.com/Widen/fine-uploader.git
cd fine-uploader
npm install http://github.com/e-jigsaw/grunt/tarball/fix-underscore-string-version
bower install
sudo npm install -g
npm install grunt
npm install
grunt package
You'll need git, NPM, Grunt & Bower.
Assuming you have git, if not install it. Then navigate to http://nodejs.org/ and INSTALL NodeJS.
From the command line:
npm install -g grunt-cli
npm install -g bower
git clone git#github.com:Widen/fine-uploader.git
cd fine-uploader
bower install
npm install -g
grunt
These are the steps that worked for me on Windows 7:
I. Install Prereqs (should only be necessary the first time)
Install node.js on windows if you haven't already.
Ensure npm has been added to your PATH variable (as of this writing, node.js puts this in during install):
%USERPROFILE%\AppData\Roaming\npm
Install git on windows if you haven't already.
Ensure the git commands have been added to your PATH variable (as of this writing the git install does not add these):
C:\Program Files(x86)\Git\bin;C:\Program Files (x86)\Git\cmd
Open command prompt.
Install grunt globally:
npm install -g grunt
Install grunt-cli globally:
npm install -g grunt-cli
Clone the repo if you haven't already:
git clone git://github.com/Widen/fine-uploader
Change command prompt directory to repo location (most likely at %USERPROFILE%\fine-uploader).
Install dependencies (if you want the dependencies installed
globally add a -g below but it is not necessary):
npm install
II. Build and Package
Open command prompt at the repo location (i.e. %USERPROFILE%\fine-uploader)
Pull latest, if necessary:
git pull
package it up:
grunt package
This should result in the files being added to the _dist folder in your repo.
The build and distribution methods have changed quite a bit over the past couple years. As of Fine Uploader 5.11, you have the following options:
Download Fine Uploader from npm
npm install fine-uploader
Download Fine Uploader from the project's home page
...at http://fineuploader.com/customize
Build Fine Uploader yourself from the GitHub repo
git clone https://github.com/FineUploader/fine-uploader.git
cd fine-uploader
npm install
make build
The "contribute code" section in the README contains even more details.

Resources