Marius
Marius

Reputation: 1072

How to use installed modules in aurelia

I am using the skeleton-typescript sample and work through the documentation. I am trying to set up a value converter with numeral as it is shown in the docs.

import numeral from 'numeral';

export class CurrencyFormatValueConverter {
  toView(value) {
    return numeral(value).format('($0,0.00)');
  }
}

I have installed numeral via jspm install numeral. It is added package.json within the jspm dependencies and I manually added it to bundles.js.

After saving the typescript file I get the error: Cannot find module 'numeral'.. What am I missing?

Upvotes: 3

Views: 804

Answers (2)

Nemanja Novicic
Nemanja Novicic

Reputation: 83

You need d.ts for numeral.js. and since there is no d.ts on Typings this can resolve problem:

$ jspm install npm:@types/numeral.

It works in my skeleton with value converters. Import can be done like import * as numeral from 'numeral';

Upvotes: 3

kabaehr
kabaehr

Reputation: 1040

You should add it in your configuration like:

export function configure(aurelia) {
    aurelia.use
        .standardConfiguration()
        .developmentLogging()
        .plugin('numeral'); 

    aurelia.start().then(() => aurelia.setRoot());
}

You will find the exact package names in your package.json:

jspm": {
   "dependencies": {
        ...
        "numeral": "xxxx"
        ...
    }
}

Upvotes: 0

Related Questions