2
votes

One reason why I can't import i18next is because the i18next.d.ts file does not have

declare module "i18next" {
    export = i18next;
}

at the end, like jquery.d.ts and knockout.d.ts have. It only has

declare var i18next: I18nextStatic;

So when I tried to import in my TypeScript file using

import i18next = require('i18next'); 

it will barf: Cannot load external module Module cannot be aliased to a non-module type

I don't know why Definitely Typed project compose the d.ts file in that way. And I don't know if declare module will be a good solution or not.

Someone please help.

1
Sounds like you need to shim the i18next library. - Jamie Dixon
Thanks for the quick answer! I will try that: ) - yanglinfang1226
And how to do it in node.js? - Tarion

1 Answers

1
votes

You probably need to Shim the i18next library so that RequireJS defines it as a module.

There's more info on the RequireJS site here: http://requirejs.org/docs/api.html#config-shim

shim : {
   'i18next' : {
      exports : 'i18next'
    }
}