Angularjs 带systemjs的Angular 2中的app.module.ts 404(未找到)
以下是我导入到index.html的内容:Angularjs 带systemjs的Angular 2中的app.module.ts 404(未找到),angularjs,angular,typescript,systemjs,Angularjs,Angular,Typescript,Systemjs,以下是我导入到index.html的内容: <script src="https://unpkg.com/core-js/client/shim.min.js"></script> <script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script> <script src="https://unpkg.com/systemjs@0.19.39/dist/
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
<script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
<script src="https://cdn.rawgit.com/angular/angular.io/b3c65a9/public/docs/_examples/_boilerplate/systemjs.config.web.js"></script>
<script>
System.import('main.js').catch(function(err){ console.error(err); });
</script>
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"inlineSources": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
}
}
奇怪的是,当所有内容都在同一个文件夹下时(如下所示):
现在一切正常。为什么呢
main.ts文件:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
tsconfig:
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
<script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
<script src="https://cdn.rawgit.com/angular/angular.io/b3c65a9/public/docs/_examples/_boilerplate/systemjs.config.web.js"></script>
<script>
System.import('main.js').catch(function(err){ console.error(err); });
</script>
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"inlineSources": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
}
}
我相信这是因为“/”是从项目的根目录开始的。可能当您删除angular2文件夹时,根目录已更改,因此main.ts导入无法找到应用程序目录要导入.ts文件,您需要在包配置中配置默认扩展名
SystemJS.config({
packages: {
"app": {
"defaultExtension": "ts"
}
}
});
然而,在您的示例中,您似乎正在导入main.js
,这与您在编写时指出的目录结构不一致
- 应用程序
- app.module.ts
- app.compontent.ts
- 梅因酒店