If you're using WebStorm 7 (which is nearly complete as I write this), I'd suggest the following steps as it's simple.
In WebStorm 7+, you can quickly get to an embedded command line for your project by using the Tools
menu option, Open Terminal...
. From there, you can manipulate the installed node packages easily. If you aren't using a version of WebStorm that has the option, simply switch to the root directory of your Node.JS application and perform the same steps.
If you don't already have a package.json
file defined for your node.js project. Add it.
You can either manually create the file or use
npm init
from the console and follow along with the prompts (press [Enter]
once or twice to move along from field to field).
You can then add esprima as a dependency manually to dependencies
as shown below:
{
"name": "nodetemp",
"version": "0.0.0",
"description": "Best demo ever",
"main": "index.js",
"repository": "",
"author": "",
"license": "BSD",
"dependencies": {
"esprima": "*"
}
}
In the example above, I've specified I wanted to use whatever the current version of esprima is located on npm.org. (Which is OK for development purposes more than likely, but less ideal for production unless carefully managed.)
Or from the command-line use npm
again:
npm install esprima --save
This will download the current version of esprima and add it as a dependency in the package.json
file. It will automatically associate the current semantic version of esprima with your package.
If you use the --save
option, it currently would add the following to the package.json
file:
"dependencies": {
"esprima": "~1.0.4"
}
Once the dependency is listed in the package.json
file, you can always use:
npm update
from the root directory of your application to update it (or download it fresh if it's not yet locally available).