Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ';反射能力';未定义的角2_Javascript_Angularjs_Webpack - Fatal编程技术网

Javascript ';反射能力';未定义的角2

Javascript ';反射能力';未定义的角2,javascript,angularjs,webpack,Javascript,Angularjs,Webpack,嘿,所以我刚开始用Angular 2使用webpack,我在尝试启动应用程序时遇到了这个错误 index.js:93未捕获类型错误:无法设置未定义的属性“reflectionCapabilities” 这是哪一行 我想这与我的网页构建/依赖性有关 这是我的网页配置文件,我用的是我正在看的一个教程 /// <binding BeforeBuild='Run - Development' /> // An attempt at a very simple webpack config f

嘿,所以我刚开始用Angular 2使用webpack,我在尝试启动应用程序时遇到了这个错误

index.js:93未捕获类型错误:无法设置未定义的属性“reflectionCapabilities” 这是哪一行

我想这与我的网页构建/依赖性有关

这是我的网页配置文件,我用的是我正在看的一个教程

/// <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];
    }
}

关于我做错了什么有什么想法吗?

通过升级到rc.1到rc.2修复了这个问题,这给了我一个不同的错误:

未捕获异常:NgZone实例化期间出错!(ApplicationRef->ApplicationRef->NgZone)


然后我通过添加
import“zone.js”修复了这个问题
t main.ts的顶部,不是最好的解决方案,但看起来它现在可以工作了

我碰巧写了那个教程,在看到你的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",
}
“依赖项”:{

“@angular/common”:“^2.0.0-rc.1”,啊,很高兴当时帮助了你,谢谢你的解释
{
  "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"
  }
}
"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",
}