2016-06-18 6 views
1

Эй, так что им просто начиная с угловыми 2 с использованием Webpack и им получать эту ошибку при попытке запуска приложения до«reflectionCapabilities» неопределенных Угловое 2

index.js:93 Uncaught TypeError: Cannot set property 'reflectionCapabilities' of undefined which is this line here

core_private_1.reflector.reflectionCapabilities = new core_private_1.ReflectionCapabilities(); 

Я предполагаю, что это что-то делать с мой WebPack сборки/зависимостями

так вот мой WebPack конфигурационный файл, который им, используя из учебника я смотрел на

/// <binding BeforeBuild='Run - Development' /> 
// An attempt at a very simple webpack config file that shows 
// the minimum required to "compile" an angular app using 
// Sass (with view encapsulation), and external HTML templates 
// 
var autoprefixer = require("autoprefixer"); 

module.exports = { 
    // Define the entry points for our application so webpack knows what to 
    // use as inputs 
    // 
    entry: { 
     app: ["./App/main"] 
    }, 

    // Define where the resulting file should go 
    // 
    output: { 
     filename: "content/[name].bundle.js" 
    }, 

    // Define the extensions that we want webpack to resolve (we need to 
    // override the default to ensure .ts files are included) 
    // 
    resolve: { 
     extensions: ["", ".ts", ".js"] 
    }, 

    // Turn on source maps for all applicable files. 
    // 
    devtool: "source-map", 

    module: { 
     loaders: [ 
      // Process any typescript or typescript-jsx files using the ts-loader 
      // 
      { 
       test: /\.tsx?$/, 
       loaders: ["ts-loader"] 
      }, 

      // Process Sass files using the sass-loader first, and then with postcss, 
      // and finally with the raw-loader so we can convert the result into a 
      // string and inject them into the 'styles' property of components (to 
      // take advantage of view encapsulation) 
      // 
      { 
       test: /\.scss$/, 
       exclude: /node_modules/, 
       loaders: ["raw-loader", "postcss-loader", "sass-loader"] 
      }, 

      // Load any HTML files into raw strings so they can be included with 
      // the angular components in-line 
      // 
      { 
       test: /\.html$/, 
       loaders: ["html-loader"] 
      } 
     ] 
    }, 

    // Configure postcss to run the autoprefixer plugin 
    // 
    postcss: function() { 
     return [autoprefixer]; 
    } 
} 

И package.json файл

{ 
    "name": "app", 
    "version": "1.0.0", 
    "main": "index.js", 
    "dependencies": { 
    "@angular/common": "^2.0.0-rc.1", 
    "@angular/compiler": "^2.0.0-rc.1", 
    "@angular/core": "2.0.0-rc.1", 
    "@angular/http": "2.0.0-rc.1", 
    "@angular/platform-browser": "^2.0.0-rc.1", 
    "@angular/platform-browser-dynamic": "^2.0.0-rc.1", 
    "es6-shim": "^0.35.1", 
    "reflect-metadata": "^0.1.2", 
    "rxjs": "5.0.0-beta.6", 

    }, 
    "devDependencies": { 
    "autoprefixer": "^6.3.6", 
    "html-loader": "^0.4.3", 
    "node-sass": "^3.7.0", 
    "postcss-loader": "^0.9.1", 
    "raw-loader": "^0.5.1", 
    "sass-loader": "^3.2.0", 
    "ts-loader": "^0.8.2", 
    "typescript": "^1.8.10", 
    "webpack": "^1.13.1" 
    }, 
    "scripts": { 
    "build": "typings install && webpack", 
    "build-watch": "typings install && webpack --watch", 
    "test": "echo \"Error: no test specified\" && exit 1" 
    } 
} 

Любые идеи о том, что им делать неправильно?

ответ

0

Мне удалось написать этот учебник, и я нашел проблему после просмотра вашего комментария reddit. Мне жаль, что вам нужно было это найти, но я рад, что вы это сделали, потому что я чему-то научился:

Проблема заключается в угловых версиях, используемых в package.json. Если вы внимательно посмотрите, вы увидите некоторые фиксированы на версии rc1, но другие (неправильно) использовать версию ^, что позволило им установить версию rc2:

"dependencies": { 
    "@angular/common": "^2.0.0-rc.1",  <-- results in RC2 now 
    "@angular/compiler": "^2.0.0-rc.1", <-- results in RC2 now 
    "@angular/core": "2.0.0-rc.1", 
    "@angular/http": "2.0.0-rc.1", 
    "@angular/platform-browser": "^2.0.0-rc.1", <-- results in RC2 now 
    "@angular/platform-browser-dynamic": "^2.0.0-rc.1", <-- results in RC2 now 
    "es6-shim": "^0.35.1", 
    "reflect-metadata": "^0.1.2", 
    "rxjs": "5.0.0-beta.6", 
} 

Как вы сказали, обновление до RC2 работал, потому что это все версии были синхронизированы. RC2 не существовал в то время, когда я написал этот пример кода, поэтому я никогда не сталкивался с этой проблемой, но теперь я знаю, что искать его.

+0

Ahh хорошо рад помочь вам тогда и спасибо за объяснение – Toxicable

1

Fixed это путем обновления до от RC.1 к РК-2, который дал мне другую ошибку:

Uncaught EXCEPTION: Error during instantiation of NgZone! (ApplicationRef -> ApplicationRef_ -> NgZone).

который я тогда неподвижную добавлением import "zone.js"; т вершины main.ts, он не лучший но похоже, что он будет работать сейчас

Смежные вопросы