在angular4应用程序中导入xml2js

在angular4应用程序中导入xml2js,angular,typescript,Angular,Typescript,我在Angular4应用程序中使用xml2js时遇到问题 我通过npm安装了它,并按如下方式导入: import {parseString} from "xml2js"; 但当我启动应用程序时,会出现以下错误: Failed to load resource: the server responded with a status of 404 (Not Found) Error: (SystemJS) XHR error (404 Not Found) loading http://local

我在Angular4应用程序中使用xml2js时遇到问题

我通过npm安装了它,并按如下方式导入:

import {parseString} from "xml2js";
但当我启动应用程序时,会出现以下错误:

Failed to load resource: the server responded with a status of 404 (Not Found)
Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/node_modules/xml2js
我也安装打字机


我是Angular(和Typescript)的新手,因此如果有人能帮助我并解释我做错了什么,我会很高兴:)

我导入了库,就像您使用Angular cli创建的干净项目导入库一样,它导入并运行良好

如果您是angular的新手,我建议您使用官方cli工具来设置项目,它可以简化与导入包相关的许多事情

如果不工作,需要运行

npm安装--保存@types/xml2js

import * as xml2js from 'xml2js';
import { parseString } from 'xml2js';