您好,我正在尝试使用 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/