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...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With