找不到模块:错误:无法解析模块' angular2 / bundles / angular2-polyfills'

时间:2016-05-12 14:00:06

标签: typescript angular webpack

我从Angular2" 2.0.0-beta.17"迁移我的项目到Angular2" 2.0.0-rc.1"

但在构建我的项目时,我得到以下错误:在cmd中

  

多层填料中的错误

     

找不到模块:错误:无法解决   模块' angular2 / bundles / angular2-polyfills'在   C:\ Users \用户akhilesh.kumar \桌面\ ang17
  @ multi polyfills

在浏览器控制台中,我收到了关注错误

Uncaught Error: Cannot find module "angular2/bundles/angular2-polyfills"
Uncaught reflect-metadata shim is required when using class decorators
Uncaught TypeError: Cannot read property 'isDefaultChangeDetectionStrategy' of undefined

我的webpack配置如下

config.entry = isTest ? {} : {
    'polyfills': ['es6-shim/es6-shim.js', 'angular2/bundles/angular2-polyfills'],
    'vendor': './src/vendor.ts',
    'app': './src/bootstrap.ts' // our angular app
  };

config.module = {
    preLoaders: isTest ? [] : [{test: /\.ts$/, loader: 'tslint'}],
    loaders: [......],
    postLoaders: [],
    noParse: [/.+zone\.js\/dist\/.+/, /.+angular2\/bundles\/.+/, /angular2-polyfills\.js/]
  };

1 个答案:

答案 0 :(得分:2)

Angular2 rc1中没有更多的angular-polyfills包。您需要手动包含ZoneJS和Reflect-metadata。

例如:

<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>