[英]Angular 2 gives SystemJS cannot find /angular2/http module
[英]Cannot find module when importing with SystemJs in Angular
我正在尝试使用 Angular 中的 SystemJs 导入外部模块
import { System } from 'systemjs';
declare const SystemJS: System;
...
SystemJs.import('./assets/example/example.js').then(m=>{
console.log('the module is', m);
});
我也试过 http://localhost:4200/assets/example/example.js
js 文件在那里并且可以访问。
但我收到一个错误:
ERROR Error: Uncaught (in promise): Error: Cannot find module 'http://localhost:4200/assets/example/example.js'
我在一个干净的项目中尝试过,它工作正常,所以我认为问题可能与一些 angular 特定配置有关。
关于什么可能是错的任何线索?
你配置过 SystemJS 吗?
像这样:
System.config({
baseURL: './src/app',
// Set paths your modules
paths: {
'example': 'assets/example/example.js'
}
});
SystemJs.import('example').then(m=>{
console.log('the module is', m);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.