gruntjs interview questions
Top gruntjs frequently asked interview questions
Why do I get the Waiting...Fatal error: watch ENOSPC
when I run the watch task ?
How do I solve this issue?
Source: (StackOverflow)
I'm trying to work out how to print a list of all available grunt tasks. With rake it would be:
$ rake -T
What's the equivalent for grunt? e.g.
$ grunt -T
Source: (StackOverflow)
When I run the command grunt
I get the following warning:
Running "karma:unit" (karma) task
Warning: No provider for "framework:jasmine"! (Resolving: framework:jasmine) Use --force to continue.
Does anybody know how to resolve this issue?
Source: (StackOverflow)
I'm using Grunt (task-based command line build tool for JavaScript projects) in my project. I've created a custom tag and I am wondering if it is possible to run a command into it.
To clarify, I'm trying to use Closure Templates and "the task" should call the jar file to pre-compile the Soy file to a javascript file.
I'm running this jar from command line, but I want to set it as a task.
Source: (StackOverflow)
I'm new to Grunt. I'm trying to configure Grunt on my Mac OSX Lion.
I followed the instructions here and then created a project folder that contains the files below. When I try to run by typing "grunt" into terminal I get command not found
. I've also modified my paths sudo nano /etc/paths
in the hope that adding the path would make the task runner work but it's still not working. Can someone assist with this please?
---paths
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/local/bin/grunt
--- files
node modules
Gruntfile.js
package.json
Source: (StackOverflow)
Does someone used node-inspector with Grunt for application debugging? If not, Can you recommend a debugging tool for Grunt based apps?
I'm working with nodejs for a server side app and I have Grunt to use separated tasks (this is because users can execute tasks separately).
Thanks in advance
Source: (StackOverflow)
We are doing a web application with AngularJS and we like the idea of using Bower for Dependency Management and Grunt for building, running tests etc. (Yeoman)
The server is done with Java using Maven, so of course we would like with a simple mvn install
build everything (web application + server)
So what approach you took and why?
1) Treat them as two different applications, which in fact they are. So using different building methods/tools is acceptable.
2) Forget about Grunt Bower, use Maven plugins to build, run tests, manage dependencies for the web application. If that is the case, which ones?
3) Use Maven exec plugin to call Grunt to build the front-end webapp. I see this more as a hack than a solution.
4) Other.
Approach easier to integrate with Jenkins is a plus.
Thanks in advance!
Source: (StackOverflow)
I'm trying to install nodeJs into my Ubuntu 14.04 in order to use GruntJs.
I've read about Ubuntu different way of doing it (issues?), so this is what I've done in order to install it:
sudo apt-get install npm
sudo npm install -g grunt-cli
Typing grunt after that I've got the error:
/usr/bin/env: node: No such file or directory
So, I've tried:
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
sudo apt-get update
And trying again, and still getting the error, I've tried:
sudo add-apt-repository https://launchpad.net/~chris-lea/+archive/node.js/
sudo apt-get install -y nodejs
I've got this message:
nodejs is already the newest version.
0 to upgrade, 0 to newly install, 0 to remove and 3 not to upgrade.
I did try a cleanup just in case:
sudo apt-get autoremove
But nope, the error is still there: when I type grunt I still get /usr/bin/env: node: No such file or directory
What should I do?
Source: (StackOverflow)
I'm trying to use Grunt as a build tool for my webapp.
I want to have at least two setups:
I. Development setup - load scripts from separate files, without concatenation,
so my index.html would look something like:
<!DOCTYPE html>
<html>
<head>
<script src="js/module1.js" />
<script src="js/module2.js" />
<script src="js/module3.js" />
...
</head>
<body></body>
</html>
II. Production setup - load my scripts minified & concatenated in one file,
with index.html accordingly:
<!DOCTYPE html>
<html>
<head>
<script src="js/MyApp-all.min.js" />
</head>
<body></body>
</html>
The question is, how can I make grunt make these index.html's depending on the configuration when I run grunt dev
or grunt prod
?
Or maybe I'm digging in the wrong direction and it would be easier to always generate MyApp-all.min.js
but put inside it either all my scripts (concatenated) or a loader script that asynchronously loads those scripts from separate files?
How do you do it, guys?
Source: (StackOverflow)
I've just started using Grunt.js. It is pretty hard to set up and I am at the point of creating a package.json
file.
Following this tutorial, it says there are 3 ways to create a package.json
file.
The first is to do npm install grunt --save-dev
But what does --save-dev
means? I tried looking but it ends in vain.
Source: (StackOverflow)
I removed the old grunt first,and I install the new grunt.But I got an error:
D:\www\grunt-test\grunt
grunt-cli: The grunt command line interface. (v0.1.4)
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
Is there haven't a grunt in my system path, or something else? I tried to re-install it for few times.
Source: (StackOverflow)
I'm new to using npm and bower, building my first app in emberjs :).
I do have a bit of experience with rails, so I'm familiar with the idea of files for listing dependencies (such as bundler Gemfile)
Question: when I want to add a package (and check in the dependency into git), where does it belong - into package.json
or into bower.json
?
From what I gather,
running bower install
will fetch the package and put it in /vendor
directory,
running npm install
it will fetch it and put it into /node_modules
directory.
This SO answer says bower is for front-end and npm is for backend stuff.
Ember-app-kit seems to adhere to this distinction from the first glance... But instructions in gruntfile for enabling some functionality give two explicit commands, so I'm totally confused here.
Intuitively I would guess that
npm install --save-dev package-name would be equivalent to adding the package-name to my package.json
bower install --save package-name might be the same as adding the package to my bower.json and running bower install?
If that is the case, when should I ever install packages explicitly like that without adding them to the file that manages dependencies (apart from installing command line tools globally)?
Source: (StackOverflow)
there are some js files in static/js/
1. a.js
2. b.js
3. c.js
how to config grunt.js to get below files:
1. a.min.js
2. b.min.js
3. c.min.js
as far, I have to type specific file name:
min: {
dist: {
src: 'js/**/*.js',
dest: 'js/min/xxx.min.js'
}
}
Source: (StackOverflow)
I'm using the font library font awesome. It works when the project is not built/uglified with grunt.
But when I'm building the project with grunt it's not working. I get this error in console: .../fonts/fontawesome-webfont.woff?v=4.0.3 404 (Not Found)
I've scaffolded the project with yeoman.
This is my ref in index.html
<!-- build:css styles/fontawesome.css -->
<link rel="stylesheet" rel='nofollow' href="bower_components/font-awesome/css/font-awesome.min.css">
<!-- endbuild -->
Any ideas what can be wrong?
Update
I need to copy the folder /bower_components/font-awesome/fonts to dist/fonts. This needs to be done in the grunt-file. Probably under the "copy" options
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,png,txt}',
'.htaccess',
'bower_components/**/*',
'images/{,*/}*.{gif,webp}',
'styles/fonts/*'
]
}, {
expand: true,
cwd: '.tmp/images',
dest: '<%= yeoman.dist %>/images',
src: [
'generated/*'
]
}]
},
But I'm not really sure where to include this.
Source: (StackOverflow)
I installed yeoman and started the examples which are provided in the official documentation.
I went through the suggested operations
yo webapp
bower install underscore
grunt
After running grunt I have the message
grunt-cli: The grunt command line interface. (v0.1.9)
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
Note that grunt have been installed with
npm install -g grunt-cli
and
npm install -g grunt
yo has generated the Gruntfile.js in the project root, where I am running the command.
The package.json has been generated as well:
"name": "testyo",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-concat": "~0.1.3",
"grunt-contrib-coffee": "~0.6.5",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-compass": "~0.2.0",
"grunt-contrib-jshint": "~0.4.1",
"grunt-contrib-cssmin": "~0.6.0",
"grunt-contrib-connect": "~0.2.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.1.3",
"grunt-contrib-watch": "~0.4.0",
"grunt-rev": "~0.1.0",
"grunt-autoprefixer": "~0.1.20130516",
"grunt-usemin": "~0.1.10",
"grunt-mocha": "~0.3.0",
"grunt-open": "~0.2.0",
"grunt-svgmin": "~0.1.0",
"grunt-concurrent": "~0.1.0",
"matchdep": "~0.1.1",
"connect-livereload": "~0.2.0"
},
"engines": {
"node": ">=0.8.0"
}
Additionally. From the root directory
grunt --version
grunt-cli v0.1.9
This confirm that grunt is available to be run in every directory.
Any idea?
Source: (StackOverflow)