PhpStorm GettingStartedwithNode.jsinPhpStorm 200116 0041 2508

download PhpStorm GettingStartedwithNode.jsinPhpStorm 200116 0041 2508

of 5

Transcript of PhpStorm GettingStartedwithNode.jsinPhpStorm 200116 0041 2508

  • 7/25/2019 PhpStorm GettingStartedwithNode.jsinPhpStorm 200116 0041 2508

    1/5

    Getting Started with Node.js in PhpStorm

    Prerequisites1. Initial configuration

    1.1. Initial configuration for a new Express app1.2. Initial configuration for a new project from existing files

    2. Configuring libraries3. Enhancing support for Express framework4. Adding npm packages to the project

    Prerequisites

    To work with Node.js in PhpStorm, the following components are required:

    Node.js interpreter and npm. These can be installed from .http://nodejs.orgThe NodeJS plugin should be enabled. This can be done through by clicking the buttoIDE Settings | Plugins Install JetBrains plugin...n.

    1. Initial configuration

    Let's go over the initial configuration steps for working with Node.js in PhpStorm

    1.1. Initial configuration for a new Express app

    Create a new project using PhpStorm. This can be done from the PhpStorm Welcome screen by clicking , or using theNew Project File | Newmenu.Project...

    In the dialog, give the project a name and set the project type toCreate New Project Node.js Express App

    PhpStorm will then locate Node.js and npm on your computer and populate the Node.js Express App configuration dialog.

    From the Node.js Express App configuration dialog, we can specify several additional options:

    Paths to Node.js and npmExpress version to useTemplate engine to useCSS engine to useWhether session support should be enabled for the application

    Tweet

    This tutorial describes how to configure PhpStorm to work with Node.js projects. Well go through the steps required to create a new Expressapp as an example.

    If Node.js is not installed, go to for more information on installation.http://nodejs.org/

    http://nodejs.org/https://twitter.com/sharehttp://nodejs.org/http://nodejs.org/https://twitter.com/sharehttp://nodejs.org/
  • 7/25/2019 PhpStorm GettingStartedwithNode.jsinPhpStorm 200116 0041 2508

    2/5

    Clicking will generate a new Express application. PhpStorm will suggest installing or locating Node.js source files that are required for properOKcode completion.

    1.2. Initial configuration for a new project from existing files

    If you are working with a Node.js project created from existing files, go to and set the path to the Node.jsProject Settings | Node.js and NPMinterpreter and download sources of the Node.js Core Modules. This will make sure the Node.js application can be run and autocompletion issupported when editing code.

  • 7/25/2019 PhpStorm GettingStartedwithNode.jsinPhpStorm 200116 0041 2508

    3/5

    2. Configuring libraries

    From the , make sure that both and libraries are checked. It willProject Settings | JavaScript | Libraries Node.js Globals Node.js Core Modulesenable code completion for Node.js:

    3. Enhancing support for Express framework

    To enhance syntax highlighting and code completion for methods from , download the corresponding TypeScript definition fileExpress module

    through by clicking the button, selecting and searching forProject Settings | JavaScript | Libraries Download TypeScript Community Stubs.Express

    4. Adding npm packages to the project

    When you open a project with directory in it, PhpStorm will suggest creating a Node.js Dependencies JavaScript library.node_modulesThis action will add these modules to the list of JavaScript libraries used by the IDE for code completion, syntax highlighting, navigationand documentation lookup.

  • 7/25/2019 PhpStorm GettingStartedwithNode.jsinPhpStorm 200116 0041 2508

    4/5

    Working with npm to install additional packages can be done by using the Local Terminal, or by going through Project Settings | Node.js and

    . From there, we can install, uninstall and upgrade npm packages in our project.NPM

    Installing a new package can be done by clicking the Install button and searching for the package to install. We can specify the package versionand optionally specify additional command line options passed to npm.

  • 7/25/2019 PhpStorm GettingStartedwithNode.jsinPhpStorm 200116 0041 2508

    5/5

    Tweet

    https://twitter.com/sharehttps://twitter.com/share