Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
js in PhpStorm
Tweet
This tutorial describes how to configure PhpStorm to work with Node.js projects. Well go through the steps required to create a new Express
app as an example.
Prerequisites
1. Initial configuration
1.1. Initial configuration for a new Express app
1.2. Initial configuration for a new project from existing files
2. Configuring libraries
3. Enhancing support for Express framework
4. 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.org.
The NodeJS plugin should be enabled. This can be done through IDE Settings | Plugins by clicking the Install JetBrains plugin... butto
n.
1. Initial configuration
Let's go over the initial configuration steps for working with Node.js in PhpStorm
PhpStorm will then locate Node.js and npm on your computer and populate the Node.js Express App configuration dialog.
If Node.js is not installed, go to http://nodejs.org/ for more information on installation.
From the Node.js Express App configuration dialog, we can specify several additional options:
Paths to Node.js and npm
Express version to use
Template engine to use
CSS engine to use
Whether session support should be enabled for the application
Clicking OK will generate a new Express application. PhpStorm will suggest installing or locating Node.js source files that are required for proper
code completion.
2. Configuring libraries
From the Project Settings | JavaScript | Libraries, make sure that both Node.js Globals and Node.js Core Modules libraries are checked. It will
enable code completion for Node.js:
When you open a project with node_modules directory in it, PhpStorm will suggest creating a Node.js Dependencies JavaScript library.
This action will add these modules to the list of JavaScript libraries used by the IDE for code completion, syntax highlighting, navigation
and documentation lookup.
Working with npm to install additional packages can be done by using the Local Terminal, or by going through Project Settings | Node.js and
NPM. From there, we can install, uninstall and upgrade npm packages in our project.
Installing a new package can be done by clicking the Install button and searching for the package to install. We can specify the package version
and optionally specify additional command line options passed to npm.
Tweet