#Phpstorm node js install
or install couple of necessary npm packages separated by space: Here is another example (installing normalize.css): In this case lodash is the name of the package. Next, to install an npm package type in the terminal: Npm's file package.json is kind of a recipe/grocery list of our project with npm packages dependencies you are installing. It will also create package.json file with the dependencies information. In your project folder this will create node_modules folder with all the packages you are installing. Then, in your project folder by using PHPStorm's terminal (or the Window's cmd) you need to initialize npm. You’ll have to set them up for each project you want them on, but if you select the template it will have everything filled out, including the path.Firstly you need to install node.js on your PC (download from HERE) To check whether it is installed properly, you will need to check node js version in cmd (or in PHPStorm's terminal) by typing: You now you have seamless minification for the project you setup the watcher for. Phpstorm does a nice job of hiding the min file under the main one in it’s structure tree also, so no extra clutter. Just continue to edit your human readable js file like normal and it will keep the min.js up to date. A little tip, don’t then access the min.js file and make a change as you’ll get files… and so forth. min.js file in the same location as your current. Go to a javascript file add a space, click away and it should generate a.
#Phpstorm node js code
Add Yui Compressor CS, Yui Compressor JS, and Code Compiler watchers with their respective templates. You’ll have to set the program path to the correct executable path even with the template though. PhpStorm even comes with prebuilt templates for these that make it super easy to setup. They check if a file meets a criteria every time you save and if so executes a command, such as minify. If you wanted you could now manually minify files, but thankfully PhpStorm provides a way to let it take care of all the work called file watchers. usr/local/lib/node_modules/closure-compiler/lib/vendor/compiler.jar usr/local/lib/node_modules/yuicompressor/build/yuicompressor-2.4.8.jar It’s faster to just open up command line and install both packages anyways.Īnd possibly the whole reason you read this article, they are now installed at: While the node.js plugin seems to come with a pretty GUI for the NPM, it just made my computers fan whirr while for several minutes while trying to get a list of available packages. We will use the Node Package Manager to install those two packages. Code Compiler will compile your code and then rebuild parts where it can safely improve efficiencies. YUI Compressor does the standard minification. Now we need to install the libraries that actually do the minification processes.
#Phpstorm node js how to
If properly installed, you will now be able to type npm into the command line and get information on how to use it. And by default everything should be symlinked so the npm command will work anywhere. A little note, /usr/local/lib/node_modules is the important directory and it should hold by default npm ( Node Package Manager ). Then go into PhpStorm and install the node.js plugin to finish that integration. Head over to and click install to download, and then run the pkg, defaults will work. Alright, lets get going.įirst, this was also my introduction to Node.js, but not to worry if it is yours too, we will only be using it as a simply command line utility. So, if you’re stuck and on windows you should be good to find specifics with a quick google.
#Phpstorm node js mac osx
It took a minute to figure out as i’m using Mac OSX Maverick, and all of the articles on it were for Windows. As a programmer it doesn’t get any better than that, so I felt very silly for not doing a good job of it over the years when I figured out this trick. If you are using PhpStorm then css and javascript minification is a set it and forget it process that requires no maintenance after setup.