当我加载在我的生产ENV页面错误,我得到以下错误:404(未找到)使用.ts文件
GET http://example.com/Scripts/main.ts 404 (Not Found) error: (SystemJS) XHR error (404 Not Found) loading http://example.com/Scripts/main.ts
这不会对我的dev发生。 ENV。
这发生在我的index.html文件中。我验证了所有路径是否正确,并且路径中存在main.ts
文件。
<script src="/Scripts/systemjs.config.js"></script>
<script>
System.import('/Scripts/main.ts').catch(function(err){ console.error(err); });
</script>
如果我改变我的main.ts
文件main.js
extention,有没有 404错误。
这里是我的systemjs.config.js文件:
(function (global) {
System.config({
transpiler: 'ts',
typescriptOptions: {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2015", "dom"],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
meta: {
'typescript': {
"exports": "ts"
}
},
paths: {
'npm:': 'https://unpkg.com/'
},
map: {
app: 'app',
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
'@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
'rxjs': 'npm:[email protected]',
'ts': 'npm:[email protected]/lib/plugin.js',
'typescript': 'npm:[email protected]/lib/typescript.js',
},
packages: {
app: {
format: 'register',
main: '/Scripts/main.ts',
defaultExtension: 'ts'
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
请参阅我在下面发布的答案。您接受的答案是对现代JavaScript工具转译器,工作流程和构建系统的完全无知。因为它是事实上不正确的,所以将其视为公认的答案将是一种耻辱。 –