Author - StudySection Post Views - 10,603 views
nodejs

Can Sublime Text be used with Node.js?

Yes, Sublime Text provides support for Node.js. So we can run nodejs app in Sublime Text.

  1. Install Sublime Text:

    • Install Sublime Text using official apt repository (or you can say Install GPG key):
      wget -qO – https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add –
    • Add the apt repository (Stable or Dev), we are using stable:
      echo “deb https://download.sublimetext.com/ apt/stable/” | sudo tee /etc/apt/sources.list.d/sublime-text.list
    • Check updates:
      sudo apt-get update
    • Install sublime-text:
      sudo apt-get install sublime-text
    • Verify whether Sublime Text is installed properly using the following command:
      subl –version
      node1
  2. Install Node.js:

    • Run the following command to install the Node.js package:
      sudo apt install nodejs
    • Set variable path using following command if not set:
      ln -s /usr/bin/nodejs /usr/bin/node
    • Verify whether Node.js is installed properly using the following command:
      node –version
      The output should be like this:node
    • Now install the Node Package Manager(npm), using the following command:
      sudo apt install npm
    • Verify whether npm is installed properly using the following command:
      npm –version
      The output should be like this:node3
  3. Make changes in Sublime Text settings as mentioned below to run Node.js in Sublime Text:

    • Open the Command Palette in Sublime Text using:
      Cmd+Shift+P
    • Type (for “Package Control: Install Package”):
      pkgctlinspkg
    • Type:
      Nodejs
    • Nodejs will be listed click on it to install.
    • Go to Preferences -> Package settings -> nodejs -> settings user
    • Now change the value of “node_command”: false, to “node_command”: “/usr/local/bin/node”
  4. Write a nodejs hello world program, save the file & build it to run it in sublime text.

    • Create a server.js file write the following code & save the file.var http = require("http");
      http.createServer(function (request, response) {
      // Send the HTTP header
      // HTTP Status: 200 : OK
      // Content Type: text/plain
      response.writeHead(200, {'Content-Type': 'text/plain'});
      // Send the response body as "Hello World"
      response.end('Hello World\n');
      }).listen(8081);
      // Console will print the message
      console.log('Server running at http://127.0.0.1:8081/');
    • Press Ctrl+B to build the node js file. Now you can see in sublime text node js server has started.node4

If you need to prove your skills in the .NET framework, get .NET certified on StudySection. StudySection provides .NET Certification Exam for beginners as well as experts in the .NET framework. This .NET certification can improve your resume’s success rate.

Leave a Reply

Your email address will not be published. Required fields are marked *

fiteesports.com rivierarw.com cratosroyalbet betwoon grandpashabet grandpashabet giriş deneme bonusu veren siteler casino siteleri