Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a custom library to a scratch file

In PhpStorm/WebStorm how can I add a custom library so that the file compiles? In my case it would be Lodash?

I tried to add lodash to global libs but it did not help...

like image 596
Amio.io Avatar asked May 13 '16 08:05

Amio.io


1 Answers

In fact, you can just add a package.json file to your scratches.

You could create one manually, but the following may be more practical:

Right click on any of your scratch files, then select "Open in terminal". You'll notice that it will open the terminal directly in the folder of the scratches. That's a folder such as C:\Users\ba\AppData\Roaming\JetBrains\WebStorm2020.2\scratches.

Since you are in the correct directory now, you can just run npm init from that terminal to create your package.json file. (You will be prompted with a bunch of questions, but you can just press enter for all questions if you are fine with the default values)

This file will just show up in your scratches along with your other files.


To answer your specific question, if you want to add lodash to those packages, you can open the terminal in the way mentioned above. This terminal will be in the correct folder. And then you can just run your npm install lodash from there.

like image 77
bvdb Avatar answered Oct 25 '22 02:10

bvdb