Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import xml2js in an angular2 app using angular-cli with webpack

For an application using angular2 (from angular-cli with webpack), i need to consume some data in xml from a soap web service.The angular-cli that i use provide natively the library xml2js for parsing xml to json but when i try to use this library in my component using the following syntax:

import {Parser} from 'xml2js';

i got the message:

Cannot find module 'xml2js'.)

However, this library is really installed on the node_modules file.

I searched everywhere but i only found some solutions with system.js config.

Does anyone know how to use this library in an angular2 using webpack?

like image 752
Sedo Avatar asked Jan 04 '23 08:01

Sedo


1 Answers

You need to install the type definitions for xml2js

NPM:

npm install @types/xml2js --save-dev

YARN:

yarn add @types/xml2js -D
like image 184
J J B Avatar answered Jan 21 '23 14:01

J J B