简体   繁体   English

System.config 未定义

[英]System.config is not defined

Hi I don't know why I have this error when I want configure my angular project :嗨,当我想配置我的 angular 项目时,我不知道为什么会出现此错误:

System.config is not a funtion

My package.json & html :我的 package.json 和 html :

 { "name": "", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \\"Error: no test specified\\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "@angular/common": "^5.2.0", "@angular/compiler": "^5.2.0", "@angular/core": "^5.2.0", "@angular/platform-browser": "^5.2.0", "@angular/platform-browser-dynamic": "^5.2.0", "reflect-metadata": "^0.1.12", "rxjs": "^5.5.0", "systemjs": "^2.0.2", "zone.js": "^0.8.26" }, "devDependencies": { "@types/core-js": "^2.5.0" } }
 <html> <head> <script src="node_modules/zone.js/dist/zone.js"></script> <script src="node_modules/reflect-metadata/Reflect.js"></script> <script src="node_modules/systemjs/dist/system.js"></script> <script> System.config({ // the app will need the following dependencies map: { '@angular/core': 'node_modules/@angular/core/bundles/core.umd.js', '@angular/common': 'node_modules/@angular/common/bundles/common.umd.js', '@angular/compiler': 'node_modules/@angular/compiler/bundles/compiler.umd.js', '@angular/platform-browser': 'node_modules/@angular/platformbrowser/bundles/platform-browser.umd.js', '@angular/platform-browser-dynamic': 'node_modules/@angular/platform-browserdynamic/bundles/platform-browser-dynamic.umd.js', 'rxjs': 'node_modules/rxjs' }, packages: { // we want to import our modules without writing '.js' at the end // we declare them as packages and SystemJS will add the extension for us '.': {} } }); // and to finish, let's boot the app! System.import('main'); </script> </head> <body> <home> Hello </home> </body> </html>

I think is the version of systemJS is to recent but I don't know more....我认为 systemJS 的版本是最近的,但我不知道更多....

Is the configuration of SystemJs changed in the latest versions? SystemJs 的配置在最新版本中是否有变化?

There seems to be some problem with the latest version of systemjs , you can downgrade it to "0.21.3" version and you will see everything will work just fine.最新版本的systemjs似乎有些问题,您可以将其降级到"0.21.3"版本,您会看到一切正常。

Checkout angular6-without-cli working repo here.在此处结帐angular6-without-cli工作仓库

Note: Make sure you do npm install before give it a try.注意:请确保在尝试之前执行npm install

It looks like the SystemJS 2 way to do this, is to put the config (as valid JSON) in a block like so:看起来 SystemJS 2 的方法是将配置(作为有效的 JSON)放在一个块中,如下所示:

<script type="systemjs-packagemap">

  {
      "map": {
          "@angular/core": "node_modules/@angular/core/bundles/core.umd.js",
          "@angular/common": "node_modules/@angular/common/bundles/common.umd.js",
          "@angular/compiler": "node_modules/@angular/compiler/bundles/compiler.umd.js",
          "@angular/platform-browser": "node_modules/@angular/platformbrowser/bundles/platform-browser.umd.js",
          "@angular/platform-browser-dynamic": "node_modules/@angular/platform-browserdynamic/bundles/platform-browser-dynamic.umd.js",
          "rxjs": "node_modules/rxjs"
        },
        "packages": {
            "main": "../main.js"
        }
    }
</script>
<script src="node_modules/systemjs/dist/system.js"></script>
<script>
    System.import('main');        
</script>

Please note, this has to be placed before the system.js script请注意,这必须放在 system.js 脚本之前

More details can be found in their docs更多细节可以在他们的文档中找到

I guess you would have upgraded to the latest system.js by mistake... which doe not support System.Config Refer to https://guybedford.com/systemjs-2.0我猜你会错误地升级到最新的 system.js... 不支持 System.Config 参考https://guybedford.com/systemjs-2.0

It is instead done using https://github.com/systemjs/systemjs/blob/2.0.0/docs/package-name-maps.md它是使用https://github.com/systemjs/systemjs/blob/2.0.0/docs/package-name-maps.md完成的

If you managed to update the code by now, might as well post the updated sample here for use of everyone.如果您现在设法更新了代码,不妨在此处发布更新后的示例供大家使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用TypeScript的Angular:ReferenceError:系统未定义System.config - Angular with TypeScript: ReferenceError: System is not defined System.config 无法使MAP在SystemJS的system.config包中工作 - can not get MAP to work within system.config packages for SystemJS Angular2的System.config-使用JavaScript还是打字稿? - System.config for Angular2 - use javascript or typescript? Angular 2 System.config映射返回404错误 - Angular 2 System.config map returning 404 error 来自单个.js文件的@angular模块的System.config映射 - System.config map for @angular modules from a single .js file 使用打字稿和Angular 2进行的业力测试正在引发“ System.config”的Typeerror - Karma testing with typescript and angular 2 is throwing Typeerror for “System.config” Angular2 Visual Studio 2017 MVC:未捕获的TypeError:System.config不是函数 - Angular2 Visual Studio 2017 MVC: Uncaught TypeError: System.config is not a function angular 2调整System.config()后单独的javascript文件和打字稿文件 - angular 2 adjust System.config() after separate javascript files and typescript files 错误参考错误:未定义配置 - ERROR ReferenceError: config is not defined Asp.net MVC5 angular4未捕获的参考错误:部署到IIS后,未在systemjs.config.js中定义系统 - Asp.net MVC5 angular4 Uncaught Reference Error: System is not defined in systemjs.config.js after deploying to IIS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM