javascriptlodashnativescriptangular2-nativescript

How do you import lodash into NativeScript Playground


I am learning NativeScript and trying to follow some tutorials while in their Playground and they are using lodash. According to NativeScripts' blog you should be able to require the lodash module in the playground, using the dropdown. (https://www.nativescript.org/blog/nativescript-playground-is-on-fire)

enter image description here enter image description here

This works and the lodash folder is added in the app folder. The problem occurs when I try to import it. It says lodash is not found. I have tried:

import * as _ from 'lodash';
import _ from 'lodash';
var _ = require ('lodash');

And many other suggestions, but none of these seem to work. I have tried add the @types (which NativeScript says they add automatically), but it fails even with the @types/lodash added.

enter image description here

Anyone know how to make this work in NativeScript playground? Thanks.


Solution

  • Try simple require statement with relative path.

    const _ = require('../lodash');