Sunday 21 May 2017

Angular2 (Typescript) can't import node module from @types

I'm trying to import log4js node module into Angular2 app, but it gives

Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/traceur

Could you guide me how to solve this issue? My app is based on quickstart angular app

I've installed @types/log4js node package, in addition to the normal package.

I've mapped module in systemjs.config.json as 'log4js':'npm:@types/log4js/index.d.ts' inside map section, adding it to packages section changes nothing 'log4js': { main: 'index.d.ts', defaultExtension: 'ts' }`

In my component, I use

import * as logger from "log4js";
let foo = logger.getDefaultLogger();

tsc --traceResolution gives the follwoing output

======== Type reference directive 'log4js' was successfully resolved to '/home/xxx/xxx/parent-folder/node_modules/@types/log4js/index.d.ts', primary: true. ========



via Dmitry Zlykh

No comments:

Post a Comment