Angular 2 系统 src 找不到核心内容(没有包)
Angular 2 System src can't find core stuff (without packages)
System.js 和 Angular 有一个有趣的问题 2.
在默认的快速启动中,我们有这个系统配置:
System.config({
packages: {
built: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('built/main')
.then(null, console.error.bind(console));
对我有用。
但是现在我尝试从构建的 upp 中移动所有文件。所以 main.js 文件与 index.html 在一个级别上。所以目前无法部署系统包。因为您需要一些文件夹名称(所有 node_modules 都正确安装在根文件夹中,并且包含所有 angular2 内容)。
我尝试使用一些简单的配置:
System.config({
defaultJSExtensions: true
});
System.import('main')
.then(null, console.error.bind(console));
但是有很多这样的错误:
system.src.js:1061 GET
http://localhost:3000/angular2/platform/browser.js 404
system.src.js:1061 GET http://localhost:3000/angular2/router.js 404
(Not Found)
感谢您的帮助!
我认为您忘记包含 Angular2 捆绑文件:
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/router.dev.js"></script -->
因为 SystemJS 可以找到它们包含的模块,所以它会尝试从 .js 加载,因为您在其配置中将 defaultJSExtensions
属性设置为 true
。
Thierry) 你又帮了我大忙。谢谢朋友:)
找到了您对类似问题最早的答案之一
你是对的。我们必须 将所有 angular js 文件保存在某个文件夹中。这个文件夹必须和index.html放在同一层级,像本地包一样注册。这是一个非常奇怪和有趣的规则,但无论如何。
System.js 和 Angular 有一个有趣的问题 2.
在默认的快速启动中,我们有这个系统配置:
System.config({
packages: {
built: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('built/main')
.then(null, console.error.bind(console));
对我有用。 但是现在我尝试从构建的 upp 中移动所有文件。所以 main.js 文件与 index.html 在一个级别上。所以目前无法部署系统包。因为您需要一些文件夹名称(所有 node_modules 都正确安装在根文件夹中,并且包含所有 angular2 内容)。
我尝试使用一些简单的配置:
System.config({
defaultJSExtensions: true
});
System.import('main')
.then(null, console.error.bind(console));
但是有很多这样的错误:
system.src.js:1061 GET http://localhost:3000/angular2/platform/browser.js 404 system.src.js:1061 GET http://localhost:3000/angular2/router.js 404 (Not Found)
感谢您的帮助!
我认为您忘记包含 Angular2 捆绑文件:
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/router.dev.js"></script -->
因为 SystemJS 可以找到它们包含的模块,所以它会尝试从 .js 加载,因为您在其配置中将 defaultJSExtensions
属性设置为 true
。
Thierry) 你又帮了我大忙。谢谢朋友:)
找到了您对类似问题最早的答案之一
你是对的。我们必须 将所有 angular js 文件保存在某个文件夹中。这个文件夹必须和index.html放在同一层级,像本地包一样注册。这是一个非常奇怪和有趣的规则,但无论如何。