Tools and Services Blog Learn Quizzes Smile API Log In / Sign Up
Tools and Services Blog Learn Quizzes Smile API Log In / Sign Up
« Return to the tutorials list
We have updated our privacy policy to let you know that we use cookies to personalise content and ads. We also use cookies to analyse our traffic and we share information about your use of our site and application with our advertising and analytics partners. By using this website or our application you agree to our use of cookies. Learn more about the way this website uses cookies or remove this message.

You can read this article in: English :: EspaƱol

Setting up Sublime Linter on Ubuntu

September 4, 2014 Difficulty: 25 / 50 Tweet
sublime-linter-screen

Hi there!

I recently switched to Ubuntu as my primary operating system and one of the issues I've encountered was setting up Sublime Linter to work properly with CSS, PHP and JavaScript linting. This gave me the idea to write this tutorial on how you can set Sublime Linter to play nicely on Ubuntu.

Install PHP, Nodejs, NPM, JSHint and CSSLint

Instead of installing PHP on its own, I've installed it alongside Apache and MySQL using tasksel so that I can enjoy the full LAMP stack locally. To install run the commands below and follow the on-screen instructions.

  
    sudo apt-get install tasksel
    sudo tasksel install lamp-server
  

The problem with installing Nodejs and use its modules as linters on Ubuntu is that you need to install the 'legacy' version in order to create the correct paths inside '/usr/bin'. Otherwise Sublime Linter will fail because it can not execute node from alternate paths. This being said, run the commands below one by one to install Nodejs, NPM, JSHint and CSSLint.

  
    sudo apt-get install nodejs-legacy
    sudo apt-get install npm
    sudo npm install -g jshint
    sudo npm install -g csslint
  

If everything went well with the installations, you should be able to see that inside '/usr/bin' there's a nodejs file, but because you installed the legacy version you will also have a symlink called node that points to nodejs which allows Sublime Linter commands to run correctly.

Install and configure Sublime Linter

Assuming you have Package Control installed in Sublime Text 3 you can now go ahead and install Sublime Linter and it's sub modules SublimeLinter-php, SublimeLinter-csslint and SublimeLinter-jshint. Once you've done that, go to Preferences » Package Settings » SublimeLinter » Settings-User and modify the configuration file by adding the correct paths to php and the node modules inside paths.linux[]. If you can't find the configuration json inside Settings-User you can copy it from the Settings-Default file and then modify it.

  
      "paths": {
          "linux": [
              "/usr/local/lib/node_modules/jshint/bin",
              "/usr/local/lib/node_modules/csslint/bin",
              "/usr/bin/php -l"
          ],
          "osx": [],
          "windows": []
      }
  

Now restart Sublime and start coding!

comments powered by Disqus