“ Cannot read property 'resolve' of undefined” error

为君一笑 提交于 2020-01-07 03:48:05

问题


I try to use SystemJS to load modules that were previously compiled into ES5. I have the following error but I don't know how to interpret the error message:

Error: Cannot read property 'resolve' of undefined(…)
  Promise.reject (async)
  g @ system.src.js:4597(anonymous function) @ system.src.js:4597
  y @ system.src.js:4597
  w @ system.src.js:4597
  p @ system.src.js:4597
  h @ system.src.js:4597
  (anonymous function) @ system.src.js:4597

Here is the configuration within my HTML file:

<script src="https://rawgithub.com/systemjs/systemjs/0.19.6/dist/system.js"></script>
(...)
<script>
  System.config({
    packages: {        
      somepackage: {
        format: 'register',
        defaultExtension: 'js'
      },
      src: {
        format: 'register',
        defaultExtension: 'js'
      }
    }
  });
  System.import('src/somefile')
        .then(null, console.error.bind(console));
</script>

Is there some debug mode / traces I can enable?

I try to use the source of Angular2 directly instead of the bundled JS files.

Thanks very much for your help! Thierry


回答1:


Lets assume that is folder node_modules publicly accessible!

If it is so, you can use this SystemJS config file:

System.config({
    defaultJSExtensions: true,
    map: {
        "app": './src',
        "angular2": 'node_modules/angular2',
        'rxjs/operator/*' : 'node_modules/rxjs/add/operator/*',
        "rxjs": 'node_modules/rxjs',
        "reflect-metadata": 'node_modules/reflect-metadata/temp/Reflect.js',
        "zone.js": 'node_modules/zone.js/dist/zone.js'
    },
    packages: {
        app: {
            defaultExtension: 'js',
            format: 'register'
        },
        angular2: {
            defaultExtension: 'js',
        },
        rxjs: {
            defaultExtension: 'js'
        },
        'reflect-metadata': {
            format: 'global'
        }
    }
});


来源:https://stackoverflow.com/questions/34860077/cannot-read-property-resolve-of-undefined-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!