WebFaction
Community site: login faq

Hello,

I want to use http://gruntjs.com/, on my server, to be able easily minify js and css, and regenerate it when needed using SSH.

I can't find any clear instruction, how to set up and use it on webfaction?

Is that has to be created as separate app? Full instructions would be appreaciated

Thanks, Aidas

asked 13 Feb '15, 10:06

Aidas Keburys
115
accept rate: 0%


Here's how to install Grunt:

  1. In the control panel, create a new Node.js application. For the rest of these steps, I'll refer to the app name as "node".
  2. SSH into your server and run the following commands:
    cd ~/webapps/node
    export PATH=$PWD/bin:$PATH
    npm install -g grunt-cli

Once that is done, you can invoke grunt from within your project directory by running ~/webapps/node/bin/grunt.

Hope that helps!

permanent link

answered 13 Feb '15, 18:28

seanf
12.2k41836
accept rate: 37%

Thanks for help

(18 Feb '15, 15:19) Aidas Keburys

You're very welcome!

(18 Feb '15, 17:05) seanf

I tried to follow these steps.

I have created Node application, installed Grunt, then I cd to the webapp that I wanted to run Grunt on and tried to run ~/webapps/node/bin/grunt

Apparently got this message: Fatal error: Unable to find local grunt.

What I'm doing wrong?

I want to use grunt to uglify some javascript files in my PHP aplication. Need a bit more detail instructions if possible, as I try to use Grunt for very first time.

(01 Mar '15, 18:35) Aidas Keburys

I don't get that error when testing this under a test account, so I'm not sure how to fix it. Do you get the same thing if exporting the PATH and using the binary explicitly from mode_modules?:

export PATH="$HOME/webapps/node/bin:$PATH"
$HOME/webapps/node/lib/node_modules/grunt-cli/bin/grunt

(The above commands assume a node application named "node")

(03 Mar '15, 07:09) ryans ♦♦

Hi Ryan,

I get following if I run the command from node_modules. Could you please explain how I configure it so it uglifies javascript files in another PHP aplication.

[couplelizer@web378 node]$ cd node_modules
[couplelizer@web378 node_modules]$ export PATH="$HOME/webapps/node/bin:$PATH"
[couplelizer@web378 node_modules]$ $HOME/webapps/node/lib/node_modules/grunt-cli                                      /bin/grunt
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: EACCES, permission denied '/home'
    at Error (native)
    at Object.fs.readdirSync (fs.js:765:18)
    at Glob._readdir (/home/couplelizer/webapps/node/node_modules/grunt/node_mod                                      ules/findup-sync/node_modules/glob/glob.js:662:20)
    at Glob._process (/home/couplelizer/webapps/node/node_modules/grunt/node_mod                                      ules/findup-sync/node_modules/glob/glob.js:446:15)
    at Glob.iterator (/home/couplelizer/webapps/node/node_modules/grunt/node_mod                                      ules/findup-sync/node_modules/glob/glob.js:181:10)
    at Array.forEach (native)
    at new Glob (/home/couplelizer/webapps/node/node_modules/grunt/node_modules/                                      findup-sync/node_modules/glob/glob.js:179:22)
    at glob (/home/couplelizer/webapps/node/node_modules/grunt/node_modules/find                                      up-sync/node_modules/glob/glob.js:57:11)
    at Function.globSync (/home/couplelizer/webapps/node/node_modules/grunt/node                                      _modules/findup-sync/node_modules/glob/glob.js:76:10)
    at /home/couplelizer/webapps/node/node_modules/grunt/node_modules/findup-syn                                      c/lib/findup-sync.js:32:19
(04 Mar '15, 12:08) Aidas Keburys

That looks like your grunt task is trying to create or modify something directly under /home, which will fail since your user doesn't have permission to do so. Maybe there's an incorrect path in your Gruntfile?

(04 Mar '15, 18:46) seanf

Hi Sean,

Could you please give me some detail instructions. What I do to configure my grunt to find some css/javascript files in another application and uglify them into production files? for e.g.: select2.css and style.css into output.min.css

After grunt-cli setup, where and how I configure it to work.

Sorry for being pain, just my first experience with grunt.

(04 Mar '15, 20:37) Aidas Keburys

I've never actually used grunt myself. Have you tried following Grunt's Getting Started instructions?

(04 Mar '15, 23:30) seanf
showing 5 of 8 show 3 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×262
×113
×57
×3

question asked: 13 Feb '15, 10:06

question was seen: 2,389 times

last updated: 04 Mar '15, 23:30

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM