typescript - webpack angular2 编译报错

标签 typescript compilation angular webpack

您好,我正在尝试使用 Webpack 编译 angular2,似乎一切正常,但出现此错误

nodecrm/node_modules/reflect-metadata/Reflect.ts
(1406,33): error TS2304: Cannot find name 'msCrypto'. 

我正在关注 Angular 网站 guid https://angular.io/docs/ts/latest/guide/webpack.html 有什么我想念的吗?我的 tsconfig.json 文件如下所示:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
    "exclude": [
            "node_modules",
            "typings/browser",
            "typings/browser.d.ts"
    ],
    "compileOnSave": true,
    "buildOnSave": false,
    "atom": {
        "rewriteTsconfig": false
    }
}

感谢您的任何建议...

最佳答案

对我来说,这是由 angular2-universal-polyfills 包引起的,该包包含旧版本的 reflect-metadata 包。 我已经通过使用 npm 下载实际的反射元数据来修复它:

npm install reflect-metadata

然后将 node_modules\reflect-metadata 文件夹复制到 node_modules\angular2-universal-polyfills\node_modules 文件夹中,并在那里重写旧的。

希望这对面临此问题的人有所帮助。我正在使用 angular2.4.5 和 webpack 处理一个旧项目。

关于typescript - webpack angular2 编译报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37906647/

相关文章:

javascript - 在 Angular 中使用 ViewChild() 获取元素

TypeScript:组织相关的类和接口(interface)

javascript - typescript :使用装饰器时的类型推断

macos - 在 Mac os 10.8 上编译 httpd 时,x86_64 出现 undefined symbol "_TLSv1_1_client_method"

angular - 如何处理 Angular 中的深层链接?

reactjs - 为什么 react-map-gl Source 不使用对象?

javascript - 如何将 html 解析为 React 组件?

c++ - 如何编译使用 PlaySound 函数的 C++ 控制台应用程序?

typescript - 子组件中的 Angular 2 ngModel 更新父组件属性

angular - 在 Angular typescript * ngFor中获取全名的首字母