Just wondering what is the command to verify the currently installed version of any grunt module already installed using command line. For example
grunt-compass -v
Or
grunt-compass --version
do not work.
Use
npm list --depth=0
You can also use grep to look for a specific package
npm list --depth=0 | grep grunt-contrib-compass
There is an npm ls alias, for short.
Perhaps you can try this, it worked for me.
grunt -version
With Python you can do something like this, in the root of your project, remembering to substitute grunt-contrib-compass for any other package installed with npm.
cat node_modules/grunt-contrib-compass/package.json | python -c "import json, sys; print json.load(sys.stdin)['version']"
This is not my code, I've adapted it from here - Parsing Json data columnwise in shell - but I've tested it and it works. :-)
If you'd rather a node/grunt solution, you can have a look at my answer here. It's based on the project's package.json, but you could adapt that to use one in the node_modules directory.
Edit: After reading Nico's answer, you could transform that output with sed to print just the version number, like so:
npm list --depth=0 | grep grunt-contrib-compass | sed "s/[^0-9\.]//g"
Related
I couldn't find a way to do e.g.:
npm list -g *json*
(Been trying npm list -g | sls json via PowerShell, but PowerShell seems to have difficulties with it as it hags for few min. after that command...)
Unfortunately there is no parameter on npm ls that enable that natively which would be a great addition.
The only solution I found so far that may help you is to use grep.
i.e.:
npm list -g | grep json
That will show only lines matching whatever you pass to grep, but that won't show the structure of dependencies correctly and then does not help to find who depends on a specific instance of that dependency, but is a start.
Is it possible to install all packages from a given scope for example:
npm install #myscope/* --save
I don't think it's possible with npm itself, but by combining your swiss army knife of unix tools – or windows tools.
I'm on Windows and using cmder to get some level of Unix tools available:
Obtain a table with all packages in the scope, columns will be separated by tabs.
Use awk to only output the first column of that table, it’s the actual package name, including the scope, like #org/package
Use that output with npm install, to actually install these packages
npm install $(npm search #org --parseable | awk '{print $1}')
I am trying to find a way to check if a particular package is installed in my project through terminal. Is there a command for that? Something like npm check redux.
you can check easily for that.
this will describe all the package installed globally
npm list -g --depth=0
this will describe all the package installed locally on your project.
npm list --depth=0
if you want to check for a particular module is installed or not.
Please use the following command in project folder.
if installed, will display package name and version installed.
if not installed, then will not display anything.
npm list --depth=0 | grep <module_name>
for more detail information please see this link. Click here for more info of your question
--depth=0 is necessary so that your terminal isn't flooded with package dependencies. if you are not use this option, you will see the all the dependencies tree.
If you are searching for specific package installed in your project, you can use one of the commands below based on what kind of terminal you use. If you are using Unix shell based terminal, you can use:
npm list --depth=0 | grep <module_name>
or if you're using windows terminal or power shell, you can use:
npm list --depth=0 | findstr <module_name>
findstr is a similar command like grep in unix shell.
Like a lot of people I am also having issues with Yeoman.
Error -bash: yo: command not found in OSx.
I tried adding export PATH=/usr/local/share/npm/bin:$PATH on my .bash_profile as suggested by some folks and still same error.
I've lost 2 hours of my productivity trying to fix Yeoman bugs and still nothing.
Does anyone know any good solution that fixes the -bash: yo: command not found ?
I found that for recent versions of npm, all node packages are installed in the ~/npm/bin/ directory.
So add those lines to your $PATH in the .profile file :
export PATH=$PATH:~/npm/bin
Then do :
source ~/.profile
yo -v
Finally found a solution for this.
First I had to uninstall and install yo again:
npm remove -g yo
npm install -g yo
I also added a symlink to the bash_profile to make yo work. The following line: PATH=${PATH}:~/.node/bin After that restart the prompt for the change to take action.
Please check this for more references: Why are my Yeoman generators installing in the wrong place?
try to add an symbolic-link (ln -s) into the /sbin -directory.
like:
ln -s /sbin/ /usr/local/share/npm/bin/yo
This also seems to work :)
sudo `yo angular2-ts [appname]`
where [appname] is the name of your app (without the []) :)
just give access for the user to read write execute in the folder webapp
sudo chmod 777 webapp
cd webapp
yo angular [appname]
I installed nodebrew, yeoman and 2 generators (generator-webapp, generator-bootstrap). But yeoman seems to don't know that generators:
$ yo webapp
Error webapp
You don't seem to have a generator with the name webapp installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 3 registered generators run yo with the `--help` option.
(When that is yo bootstrap, similar error is occurred.)
So I run yo --help, but it doesn't show any generators:
$ yo --help
Usage: yo GENERATOR [args] [options]
General options:
-h, --help # Print generator's options and usage
-f, --force # Overwrite files that already exist
But I run yo with no args, generators are shown:
$ yo
? 'Allo mehtats! What would you like to do? (Use arrow keys)
Run a generator
❯ Bootstrap
Webapp
Mocha
──────────────
Update your generators
Install a generator
Find some help
Get me out of here!
──────────────
Then I choose Webapp and run this generator, an error is occurred:
Make sure you are in the directory you want to scaffold into.
This generator can also be run with: yo webapp
_-----_
| | .--------------------------.
|--(o)--| | Welcome to Yeoman, |
`---------´ | ladies and gentlemen! |
( _´U`_ ) '--------------------------'
/___A___\
| ~ |
__'.___.'__
´ ` |° ´ Y `
Out of the box I include HTML5 Boilerplate, jQuery, and a Gruntfile.js to build your app.
? What more would you like? Bootstrap
create Gruntfile.js
create package.json
create .gitignore
create .gitattributes
create .bowerrc
create bower.json
create .jshintrc
create .editorconfig
create app/styles/main.css
create app/favicon.ico
create app/robots.txt
create app/index.html
create app/scripts/main.js
Error
You don't seem to have a generator with the name mocha installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 3 registered generators run yo with the `--help` option.
I referred to other questions and do npm install --force -g webapp, but it wasn't solved.
yo doctor said:
$ yo doctor
[Yeoman Doctor] Everything looks all right!
Versions:
$ yo -v
1.4.0
$ node -v
v0.11.14
Along with using npm install directly, you can search for generators via the Yeoman interactive menu. Run yo and select Install a generator to search for published generators.