intellij-ideaphpstormwebstormjetbrains-idescratch-file

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...


Solution

  • Using require and relative paths.

    Here is a crazy example of using lodash in a scratch file:

    const _ = require('./../../../DEV/node_modules/lodash');
    
    var anything = [1, 2];
    
    _.map(anything, function (item) {
        console.log('Working >-P');
        return item;
    });