[英]Uncaught ReferenceError: System is not defined angular 4
I installed angular2-recaptcha in my project ( https://github.com/xmaestro/angular2-recaptcha ). 我在我的项目中安装了angular2-recaptcha( https://github.com/xmaestro/angular2-recaptcha )。
I have added systemjs.config.js : 我添加了systemjs.config.js :
System.config({
map: {
'angular2-recaptcha': 'node_modules/angular2-recaptcha'
},
packages: {
app: {
format: 'register',
defaultExtension: 'js'
},
'angular2-recaptcha': {defaultExtension: 'js', main:'index'}
}
});
index.html : index.html :
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){
console.error(err);
});
</script>
But I am getting this error in browser console: 但我在浏览器控制台中收到此错误:
Uncaught ReferenceError: System is not defined
at localhost/:29
compiler.es5.js:15996 Uncaught Error: Unexpected module 'ReCaptchaModule' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation.
at syntaxError (compiler.es5.js:1690)
at compiler.es5.js:15430
at Array.forEach (<anonymous>)
at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver.getNgModuleMetadata (compiler.es5.js:15412)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._loadModules (compiler.es5.js:26795)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileModuleAndComponents (compiler.es5.js:26768)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync (compiler.es5.js:26697)
at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_._bootstrapModuleWithZone (core.es5.js:4536)
at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_.bootstrapModule (core.es5.js:4522)
at Object.../../../../../src/main.ts (main.ts:11)
Please help me! 请帮我! Where is my mistake?
我的错误在哪里?
You need to load SystemJS
library, not only the config: 您需要加载
SystemJS
库,而不仅仅是配置:
<script src="systemjs/dist/system.js"></script> <---------------------
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
Also, System
usage is deprecated, use SystemJS
where System
is global object is expected, for example instead of System.import
use SystemJS.import
. 此外,不推荐使用
System
使用,使用SystemJS
,其中System
是全局对象,例如,而不是System.import
使用SystemJS.import
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.