PyCharm provides integration with the Meteor framework. Meteor support in PyCharm involves:
-
Automatic recognition of Meteor projects by detecting the
.meteor
folder and excluding the.meteor/local
folder from project. - Attaching the predefine Meteor library to the project automatically.
- Coding assistance: syntax highlighting, code completion, resolving references.
- Support of Spacebars via Handlebars with completion for if and each directives. There is also support for navigation between JavaScript source code and templates, allowing for easy navigation by using Ctrl+B, Ctrl+Button1 Click or Button2 Click to go to Declaration.
- Running and debugging the server and the client sides of applications.
On this page:
- Before You Start
- Installing Meteor
- Preparing to Develop a Meteor Application
- Running and Debugging a Meteor Application
-
Make sure the Meteor and the Handlebars/Mustache plugins are activated.
The Handlebars/Mustache enables PyCharm to recognize Spacebars templates that are an extension of the Handlebars/Mustache templates.
As a side effect, HTML files in Meteor projects are marked with the Handlebars/Mustache icon
.
The plugins are not bundled with PyCharm, but they are available from the PyCharm plugin repository.
Once enabled, the plugins are available at the IDE level, that is, you can use it in all your PyCharm projects. See Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins for details.
The installation procedure depends on the operating system you are using:
-
To install Meteor on Windows, download the
LaunchMeteor.exe
installer at https://github.com/meteor/meteor/wiki/Preview-of-Meteor-on-Windows.
-
To install Meteor on OSX (OSX 10.6 or higher is required) or Linux, type the following command:
$ curl https://install.meteor.com | /bin/sh
Learn more at http://docs.meteor.com/.
Preparing to Develop a Meteor Application
To start your development, you need a PyCharm project with the Meteor-specific structure. You can have an application stub that meets these requirements generated automatically or open an existing Meteor project in PyCharm and configure Meteor support in it.
- Choose New Project button on the Welcome screen. The Create New Project: Select Project Type dialog box opens. on the main menu or click the
- In the left-hand pane, choose Meteor JS App.
-
In the right-hand pane:
- In the Location text box, specify the path to the project folder where the project-related files will be stored.
- Specify the location of the Meteor executable file (see Installing Meteor), and choose the sample to generate from the Project Template drop-down list. To have a basic project structure generated, choose the Default option.
When you click Create, PyCharm generates a skeleton of a Meteor application, including an HTML file, a JavaScript file, a CSS file,
and a .meteor
folder with subfolders.
The .meteor/local
folder, which is intended for storing the built application,
is automatically marked as excluded and is not involved in indexing.
By default, excluded files are shown in the project tree. To have the .meteor/local
folder hidden,
click the button on the toolbar of the Project tool window and remove a tick next to the Show Excluded Files option.
PyCharm also automatically attaches the predefined Meteor library to the project, thus enabling syntax highlighting, resolving references, and code completion. See Configuring JavaScript Libraries for details.
Meteor uses Spacebars templates that are an extension of the Handlebars/Mustache templates.
PyCharm recognizes Spacebars templates, but as a side effect marks HTML files in Meteor projects
with the Handlebars/Mustache icon .
PyCharm automatically detects Meteor projects by locating the .meteor
folder.
The .meteor/local
folder, which is intended for storing the built application,
is automatically marked as excluded and is not involved in indexing.
- Open the desired Meteor project in PyCharm by choosing on the main menu or clicking Open on the Welcome Screen.
- Open the Settings dialog box by choosing . Expand the Languages&Frameworks node, and then click Meteor under JavaScript.
-
On the Meteor page that opens:
- Check the location of the Meteor executable file or specify the path to it if PyCharm has not detected the executable file automatically.
-
To have PyCharm involve the
.meteor/local
folder and its contents in indexing, clear the Automatically exclude ".meteor/local" directory on open project check box. By default, the check box is selected and the.meteor/local
folder, which is intended for storing the built application, is automatically marked as excluded and is not involved in indexing.By default, excluded files are shown in the project tree. To have the
.meteor/local
folder hidden, click thebutton on the toolbar of the Project tool window and remove a tick next to the Show Excluded Files option.
- Click Apply to save the settings without leaving the dialog box.
-
Check that PyCharm has attached the Meteor library to the project:
- Click Libraries under JavaScript.
- On the JavaScript. Libraries page that opens, make sure the check box next to the Meteor project library in the Libraries list is selected.
- Click OK.
Alternatively, choose Use JavaScript Library on the context menu of the editor and make sure a tick is set next to Meteor project library.
By default, excluded files are shown in the project tree. To have the .meteor/local
folder hidden,
click the button on the toolbar of the Project tool window and remove a tick next to the Show Excluded Files option.
PyCharm also automatically attaches the predefined Meteor library to the project, thus enabling syntax highlighting, resolving references, and code completion. See Configuring JavaScript Libraries for details.
Besides the predefined Meteor library that ensures basic Meteor-specific coding assistance,
you can download additional packages that are defined in the
.meteor/local/packages
file.
-
Open the
.meteor/local/packages
file in the editor. - Click the Import Meteor Packages link in the upper right-hand corner of the screen.
-
In the dialog box that opens, specify the packages to download depending on the type of the application you are going to develop in your project.
- Client
- Server
-
Cordova: choose this option to import the packages that support development of Meteor applications
for iOS and Android,
see Meteor Cordova Phonegap Integration
for details.
Running and Debugging a Meteor Application
With PyCharm, you can debug both the client-side and the server-side of Meteor JavaScript code simultaneously using the PyCharm debugger.
Meteor applications are launched only through a dedicated run configuration. Technically, several Meteor projects that implement different applications can be combined within one single PyCharm project. Each of them can be executed independently according to a separate run configuration with the relevant working directory specified. The results are shown in the console and/or in the browser depending on the settings specified in the Browser / Live Edit tab, see Creating a run configuration below.
In the debugging mode, PyCharm provides the Live Edit functionality which supports both automatic and manual upload of updated files on the server side. For the client side, Live Edit does not provide any way to apply the changes. For information on enabling and configuring the Live Edit functionality, see Live Editing of HTML, CSS, and JavaScript.
Technically, PyCharm creates separate run configurations for the server-side and the client-side code, but you specify all your settings in one dedicated Meteor run configuration.
-
On the main menu, choose Edit Configuration dialog box, that opens, click the Add New Configuration toolbar button
, and choose Meteor on the context menu.
.
In the -
In the Configuration tab of the Run/Debug Configuration: Meteor dialog box that opens, specify the following:
- The name of the configuration.
- The location of the Meteor executable file according to the installation (see Installing Meteor).
-
Optionally, in the Program Arguments field,
specify the command line additional parameters to be passed to the executable file on start up, if applicable.
These can be, for example,
--dev
,--test
, or--prod
to indicate the environment in which the application is running (development, test, or production environments) so different resources are loaded on start up. -
In the Working Directory field,
specify the folder under which the application files to run are stored.
This folder must contain a
.meteor
folder in the root to be treated a Meteor projects.Technically, several Meteor projects that implement different applications can be combined within one single PyCharm project. Each of them can be executed independently according to a separate run configuration with the relevant working directory specified. By default, the field shows the path to the PyCharm project root.
-
Switch to the Browser / Live Edit tab and configure the behaviour of the browser:
- To view the results of the client-side code execution during running and debugging, select the After Launch check box and choose the browser to open from the drop-down list.
-
In the text box below, specify the URL address to open the application in. The default value is
http://localhost:3000
. - To enable debugging the client-side code in the browser, select the With JavaScript Debugger check box.
- Click OK to save the run/debug configuration.
Configuring the Update Policy in the Debugging Mode
In the debugging mode, PyCharm provides the Live Edit functionality which supports both automatic and manual upload of updated files on the server side. For the client side, Live Edit does not provide any way to apply the changes.
For information on enabling and configuring the Live Edit functionality, see Live Editing of HTML, CSS, and JavaScript.
The client-side code can be updated
through the native Meteor hot code pushes functionality.
- Open the Settings dialog box by choosing . Expand the Debugger node under Build, Execution, Deployment, and then click Live Edit. The Live Edit page that opens.
-
In the Update area,
configure the way changes made to the code during a debugging session are applied.
This functionality is available only for the server-side code. To have the client side code updated,
select the Enable Meteor 'Hot code push' check box on the Meteor page of the Settings dialog box.
Note that an update will be performed only if none of the modified files have any syntax errors.
- Auto in (ms): Choose this option to have the changes applied automatically at certain time interval and specify the delay in ms in the text box. This policy is not available for the client-side code of Meteor applications.
-
Manual: Choose this option to apply the changes manually by clicking
the Update <run configuration name> JavaScript button
or the Update <run configuration name> button
on the toolbar of the Debug tool window.
It is recommended that you choose this option because applying changes to the client-side code is not supported.
-
Restart if hotswap fails:
With changes in HTML, CSS, and JavaScript on the client side, the contents of a Web page in the browser are updated without reloading. For NodeJS or Meteor applications, PyCharm first tries to update the application incorporating the changes without restarting the NodeJS server.
-
Select this check box to have PyCharm try restarting the server if the changes cannot be applied automatically.
After the restart, PyCharm brings you to the execution point where the problem took place.
If even with this option chosen automatic upload still fails, tou will have to restart the server manually by clicking the Rerun <run configuration name> button
.
- When the check box is cleared, PyCharm just displays a pop-up window informing you about the failure and suggesting you to restart the server manually.
-
Select this check box to have PyCharm try restarting the server if the changes cannot be applied automatically.
After the restart, PyCharm brings you to the execution point where the problem took place.
The client-side code can be updated
through the native Meteor hot code pushes functionality.
The functionality is enabled by default, to activate it:
- Open the Settings dialog box by choosing . Expand the Languages&Frameworks node, and then click Meteor under JavaScript.
- On the Meteor page that opens, select the Enable Meteor 'Hot code push' check box.
-
To run an application,
select the required run configuration from the list on the main tool bar
and then choose Run toolbar button
.
If in the run configuration the browser is configured to open automatically upon application start, the browser opens showing the result of application execution. You can view the same result by opening the browser of your choice manually at the URL specified in the run configuration.
on the main menu or click the
- Set the breakpoints in the code, where necessary.
-
To initiate a debugging session,
select the required debug configuration from the list on the main tool bar
and then choose Debug toolbar button
. The Debug tool window opens showing two tabs: one for debugging the server-side code marked with
and the other for debugging the client-side code marked with
.
on the main menu or click the - Explore the suspended program and step through the program.
-
Apply the changes to the application depending on the update policy defined in the run configuration:
-
To apply the changes to the client-side code, switch to the
tab and click the Update <run configuration name> JavaScript button
on the toolbar.
-
The changes to the server-side code are applied depending on the update policy defined in the run configuration:
-
If you have chosen manual upload, switch to the
tab and click the Update <run configuration name> button
on the toolbar.
-
If you have chosen automatic upload, updates to the server-side code are applied automatically.
If automatic upload fails, restart the application by clicking Rerun <run configuration name> button
. Choosing the Restart if hotswap fails option on the Live Edit page may help: PyCharm will attempt to restart the server automatically.
-
If you have chosen manual upload, switch to the
-
To apply the changes to the client-side code, switch to the