FAQ Database Discussion Community


How to load a task using loadNpmTask in gruntfile if module is in different directory

javascript,gruntjs,gruntfile
Trying to load module: grunt.loadNpmTasks('grunt-express-server'); from an external directory. Get an error: task .... does not exist. Have you loaded it? Directory structure: client/ node_modules gruntfile dev_server/ node_modules/ grunt-express-server So my question is: how do you run a grunt-task using a node-module which is stored in a external directory? ...

What does slash dot refer to in a file path?

windows,git,gruntjs,filepath,slash
I'm trying to install a grunt template on my computer but I'm having issues. I realized that perhaps something different is happening because of the path given by the Grunt docs, which is %USERPROFILE%\.grunt-init\ What does that . mean before grunt-init? I've tried to do the whole import manually but...

SailsJS: Requiring Assets, Such As, sails.io.js

javascript,node.js,socket.io,gruntjs,sails.js
As the problem is short & sweet, I'll keep the question so. CAN'T LOAD ASSETS. Using Sails.js (v0.11.n). Can't load assets... That's about it... I'm trying to load sails.io.js -- or now even just assets/alert.js. <script type="text/javascript" src="/js/dependencies/sails.io.js"></script> Doesn't work :( Even when I switch the src to /alert.js --...

Yeoman angular dist version of app, does not restrict the direct folder access

angularjs,.htaccess,gruntjs,yeoman-generator,yeoman-generator-angular
I am facing this issue for my angular app. Dist version of app, does not restrict the direct folder access. so www.mysite.com/scripts and /images and /styles folder are accessible. This issue is not coming in development i.e. grunt serve this is coming in grunt serve:dist. I have tried the deny...

Grunt : Usemin prepare, options for cssmin

gruntjs,grunt-usemin,grunt-contrib-cssmin
I'm using usemin in my Grunt file. I'd like to use purifycss. BUT, i get this error when running grunt : Warning: Please check the validity of the CSS block starting from the line #1 Use --force to continue. I think it's because Font Awesome is the first library in...

Grunt-contrib-copy: variables within the rename function

javascript,gruntjs,grunt-contrib-copy
I have the following copy task in a gruntfile.js copy: { css: { expand: true, cwd: 'min/css', src: 'theme_<%= props.majorversion %>.<%= props.minorversion %>.min.css', dest: 'dest/dir/', rename: function(dest, src) { return dest + src.replace('_<%= props.majorversion %>.<%= props.minorversion %>',''); } } } Currently, the file is copied successfully but once copied, I'd...

Getting undefined with custom function execution in grunt task

gruntjs
Try to execute below custom task: 'use strict'; module.exports = function(grunt) { grunt.initConfig({ log: { one: [1, 2, 3], two: "Hello World", three: true, four: { five: function() { grunt.log.writeln("Hi"); }, six: function() { grunt.log.writeln("Welcome"); } } } }); grunt.registerMultiTask('log', 'Log stuff', function() { grunt.log.writeln(this.target + ": " + this.data...

Does an existing gruntfile need to be edited? What is the common workflow?

angularjs,gruntjs,yeoman,bower
For an existing app, is there a proper protocol for specifying bower packages such that they're handled correctly when running "grunt build"? Does an existing gruntfile need to be edited? What is the common workflow?

Yoeman task “autoprefixer:dist” gets stuck

angularjs,gruntjs,autoprefixer
I'm pretty new to grunt workflow. I have installed https://github.com/DaftMonk/generator-angular-fullstack. When i run grunt serve, its gets stuck at autoprefixer:dist task. When I commented out autoprefixer task the rest of the task go through and I get the app running. Not sure whats wrong. Please help me get rid of...

How to use dynamic values in Grunt tasks called from inside a forEach?

foreach,gruntjs,grunt-contrib-copy
We are trying to run grunt tasks using grunt.config.set for dynamically concatinated strings. These grunt.configs are set in a forEach loop and change each time before the task is run. This does unfortunately not work, as grunt only uses the last grunt.config.set and runs it multiple times with that very...

Writing multiple functions in AMD javascript module

javascript,gruntjs,amd
I am quite new to writing javascript code using AMD. I am stuck at figuring out how to write multiple functions in a file: define(function(){ return { and: function(a,b){ return (a&&b); } }; } ); I tried writing another function plus in the following way: define(function(){ return { plus: function(a,b){...

Error using Grunt watch and SASS

node.js,sass,gruntjs
I am trying to use grunt watch t with SASS on Windows, but everytime I get an error Waiting... OK >> File "scss\main.scss" changed. Running "sass:dist" (sass) task Error: Error generating source map: couldn't determine public URL for the source stylesheet. No filename is available so there's nothing for the...

Why doesn't postinstall run everytime?

jenkins,gruntjs,npm
I have a package.json file that has the following JSON at the bottom. "scripts": { "postinstall": [ "./node_modules/bower/bin/bower install && ./node_modules/protractor/bin/webdriver-manager update" ] } My reason for having this is so bower dependencies and my protractor tests will run after an "npm install". However, it seems that "postinstall" doesn't always...

Add locale moment to an AngularJS app

angularjs,gruntjs,momentjs
I'm trying to configure the locale language for an AngularJS app based on Yeoman. When I serve the dist package after building my app (grunt build), the script reference dissapears. Here's a list of my dependencies on the index.html file. <!-- build:js(.) scripts/vendor.js --> <!-- bower:js --> <script src="bower_components/jquery/dist/jquery.js"></script> <script...

generating templates with grunt - looking for a task

javascript,node.js,templates,gruntjs,task
I've got an HTML file with following content: <html> <body> <span>{{ secret }}</span> </body> </html> I'm looking for a grunt task that could take this source file, take a map of values: grunt.initConfig({ myTask: { myTarget: { src: ... dest: ... values: { secret: 'ABC' } } } }) and...

Grunt start Node Server and then open browser

javascript,node.js,gruntjs,connect
I have grunt task that starts the server: module.exports = function(grunt){ grunt.registerMultiTask('connect', 'Run a simple Node Server', function(){ var options = this.options(); // Tell Grunt this task is asynchronous. var done = this.async(); var server = connect(); server.use(function(request, response, nxt){ ... }); server.listen(port); }); }; Now I want to use...

Sailsjs with angularjs npm install error

angularjs,gruntjs,npm,sails.js
i am using sails js backend and frontend angularjs. i have given npm install. npm install package show this error: npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements! npm ERR! peerinvalid Peer [email protected] wants [email protected]~0.4.0 npm ERR! peerinvalid Peer [email protected] wants [email protected]>=0.4.0 npm ERR! peerinvalid...

Grunt Build Aborted Due to Warnings

angularjs,gruntjs,yeoman,karma-jasmine,yeoman-generator-angular
I'm new to angular and I'm working with Yeoman scaffolded apps and Grunt. I successfully created a few Grunt builds earlier on in the project but now when I do: Grunt build I get the following message: I'm not sure how to interpret the command line output which is below....

Using npm to install grunt on nodeenv results in findup-sync error

node.js,gruntjs,npm
After establishing a node virtualenv using nodeenv, I use source /bin/activate to switch into the correct directory, update npm, and execute npm install -g grunt or npm install -g grunt-cli and I recieve the same error: npm ERR! Linux 3.13.0-53-generic npm ERR! argv "node" "/home/{redacted-home-dir}/NodeProjects/vue/bin/npm" "install" "-g" "grunt-cli" npm ERR!...

grunt-contrib-cssmin : Relative path of images is not replaced in target minified file

css,gruntjs,relative-path,grunt-contrib-cssmin
I am using grunt-contrib-cssmin, for the minification of my css files. I want the relative urls in the css files to be replaced automatically in my target minified file. I have looked for this problem and found the two options that I can use to replace the url, target, root...

How to run multiple application on Grunt

angularjs,gruntjs,server
I have two applications say applicationA and applicationB and if I run following command on terminal grunt serve my one applicationA will up and work fine. when i need to run applicationB, first i need to stop applicationA and then i can run applicationB. If i try to run both...

How to get Bower Install to copy files to another directory before linking them in html file?

gruntjs,bower-install
In my gruntfile.js I am using bower install to create the necessary script tags in my index.html for all my js libraries. My grunt file entry looks like this: bowerInstall: { target: { src: ['wwwroot/index.html'], cwd: '', dependencies: true, devDependencies: true, exclude: [], fileTypes: {}, ignorePath: '', overrides: {} }...

Changing JS variable with Grunt for different environments

javascript,build,gruntjs,environment-variables
I'm trying to configure my JS build to do next: I'm using a JS variable to define the application root: globals.js define(function (require) { "use strict"; return { mainRoot: "http://myapp.com" //mainRoot: "http://localhost:3000" - local run //mainRoot: "http://myapp-test.com" - test server }; }); During local development I'm using code without Grunt...

Force grunt-typescript to use node_modules/.bin/tsc

node.js,gruntjs,typescript
How do I force grunt-typescript to use the local typescript instance in my node_modules/.bin folder? My global instance of typescript is 1.4 and I want to try out 1.5Beta without affecting any other project I have.

How to setup grunt-babel to transpile an entire directory

gruntjs,babel,transpiler
So I have this in my gruntfile: gruntConfig.babel = { options: { sourceMap: true }, dist: { files: { "dist/server.js": "src/*.js" } } }; This correctly transpiles all the js files in src, but it overwrites dist/server.js every time. This must be really simple, but I can't seem to figure...

need to generate css from scss file on windows 8.1 using gruntjs compass

css3,sass,gruntjs,grunt-contrib-watch
I am working on a and facing problem to generate tabs.css file from the tabs.scss that is being provided . I have tried all possible options. I am able to successfully generate tabs.js under dist/ folder but failing to generate tabs.css. I have run the following commands also: npm install...

Compass file path errors in Grunt

angularjs,gruntjs,yeoman,compass,grunt-contrib-compass
in Gruntfile.js: compass: { options: { sassDir: '<%= yeoman.app %>/styles', cssDir: '.tmp/styles', generatedImagesDir: '.tmp/images/generated', imagesDir: '<%= yeoman.app %>/images', javascriptsDir: '<%= yeoman.app %>/scripts', fontsDir: '<%= yeoman.app %>/styles/fonts', importPath: '<%= yeoman.app %>/bower_components', httpImagesPath: '../images', httpGeneratedImagesPath: '../images/generated', httpFontsPath: '/styles/fonts', spriteLoadPath: '<%= yeoman.app %>/styles/sprites/', relativeAssets: true,...

Using grunt for front end with php

php,html,gruntjs
Forgive me, I'm new to Grunt and I don't typically code PHP. This is a new project for me. I'm trying to use Grunt, because it's awesome, with some html files that have minimal php in them. I originally installed the regular grunt, not the php grunt. Now I realize...

When using Libsass/Grunt is there a way to watch files on the fly?

css,sass,gruntjs,zurb-foundation-5,libsass
I have installed Foundation 5 using >gem install foundation And then creating a new project using the command >foundation scratch --libsass The main reason being is that I'm on Windows and I really don't need/want to be using compass. I know that after I make changes to my sass files...

Error 'uiGrid' must have exactly one root element. ui-grid/ui-grid when UI-Grid is initiated

angularjs,gruntjs,ng-grid,angular-ui-grid
While trying to add ui-grid to an angular project, I came across this issue. I’ve bootstrapped the angel;ar application with ui-grid dependency injected. var app = angular.module(‘myApp’,
 ['ui.bootstrap',
 'services',
 'filters',
 'directives',
 'controllers',
 'ui.grid'
 ]); The controller looks like this. angular.module('controllers').controller('UIGridCtrl',function UIGridCtrl($scope) {
 $scope.init = function(){
 $scope.myData = [
 {"firstName": "Cox",...

grunt-http-server is stop running

gruntjs
I am trying to use the grunt-http-server https://www.npmjs.com/package/grunt-http-server I follow the example that is on the link 'http-server': { 'dev': { // the server root directory root: apps, // the server port // can also be written as a function, e.g. // port: function() { return 8282; } port: 8282,...

$http.get returns actual php script instead of running it (yeoman, grunt)

php,angularjs,pdo,gruntjs
I'm building a "simple" AngularJS app with an articles newsfeed. My articles are stored in a mysql database, and I extract them using php PDO. I used to do this using AJAX with a simple LAMP configuration (php5, mysql, apache2), and everything worked as intended. Now I'm trying to rebuild...

When starting Nightwatch with Grunt, the website server is not started

javascript,node.js,selenium,gruntjs,nightwatch.js
I am using Nightwatch.js to run system tests for a website. I want to automate the tests by running them via grunt. My Gruntfile contains these lines: ... var nightwatch = require('nightwatch'); nightwatch.initGrunt(grunt); ... nightwatch: { options: { standalone: true, test_settings: { "default": { "launch_url": "http://localhost", "selenium_port": 4444, "selenium_host": "localhost",...

pass middleman variable to grunt file

javascript,gruntjs,html-email,middleman
My middleman template has an 'id' variable that I put my html emails job name into. I know if I change my middleman erb file from index.html.erb to newName.html.erb it will output that as the final files name. My problem is that most of my grunt tasks require the file...

How to define bourbon and neat in grunt js file / windows 8 user?

gruntjs,bourbon,neat
I'm trying to use this code and I get error for using "loadPath" duplicated. options: { style: "compressed", sourcemap : true, loadPath: require('node-bourbon').includePaths, loadPath: require('node-neat').includePaths }, ...

I can not use grunt -cli and grunt serve in my web hosting

node.js,gruntjs,grunt-cli
I have developed a website on Node.js that runs perfectly on my local machine. I run my server with the command: $ grunt serve The problem is when i run my web application on my server online ( gandi server ). I can't use the command $ grunt serve Because...

How can I minify my index.php using grunt?

php,html,optimization,gruntjs,minify
I want to achieve this using grunt Goal My main goal is to minify my index.php before placing them on my production server. It's simple if I have 1 single index.html, but I don't. Instead I have an index.php full with other .php files. Each <?php ?> section is...

apt-get install -g grunt grunt-cli missing modules

node.js,gruntjs
I'm using a Ubuntu 14.04 server and am trying to install grunt & grunt-cli with this command: npm install -g grunt grunt-cli Everything looks fine, no errors are recieved. But when I run the standard grunt command, I recieve this error: module.js:338 throw err; ^ Error: Cannot find module 'eventemitter2'...

Is there a way to specify variable in grunt task name?

gruntjs
Is there a way to specify variable in grunt task name? I would like to do something like grunt build version 0.1 and then in gruntfile.js grunt.initConfig({ version: // read that version files: { '<%= version %>.js' ...

grunt-contrib- packages are officially supported by Grunt?

javascript,gruntjs,requirejs,r.js,grunt-contrib-requirejs
I'm about to use the RequireJs plugin for Grunt. I found out that there are two plugins with the same functionality: grunt-contrib-requirejs (https://github.com/gruntjs/grunt-contrib-requirejs) grunt-requirejs (https://github.com/asciidisco/grunt-requirejs) I am wondering if -contrib prefixed plugins are the trusted, maintained and officially supported ones by Grunt? Is this a pattern that developers should look...

Yeoman angular grunt-serve vs http-serve

angularjs,gruntjs,npm,yeoman,http-server
I've just used Yeoman to create an Angular project that looks great when I run grunt serve. But then I decided to view it by running http-server, and the page gets displayed without the formatting and without the images. Does anyone know why that is and if I'll run into...

Node module to execute tasks grunt : “Gruntfile.js” not find

javascript,node.js,command-line,gruntjs
I'm currently trying to develop a module that will allow node to run Grunt tasks from the command line. This Node module is installed globally : C:\Users\pcharpin\AppData\Roaming\npm\node_modules\task-app The goal is that the use of "Grunt" commands is transparent to the user. To better explain my approach, a simple example of...

Message appears when running scsslint

sass,gruntjs
I am following the step by step on https://www.npmjs.com/package/grunt-scss-lint I have installed everything, and seems to be working fine when I type in Terminal 'scss-lint'. However I want this to be running in Grunt Gruntfile: scsslint: { allFiles: [ 'src/scss/**/*.scss', ], options: { bundleExec: true, config: '.scss-lint.yml', reporterOutput: 'scss-lint-report.xml', colorizeOutput:...

Grunt inject CSS file into