Angular 2 - 移动到@types给出错误“找不到名字'require'”

时间:2016-10-19 07:20:26

标签: angular typescript

我已将项目从旧版本移至类型发布者。除了我不断收到此错误找不到名称'require',我的大多数依赖项都已解决 这是我的tsconfig.json

"@types/angular": "^1.5.16",
    "@types/core-js": "^0.9.34",
    "@types/googlemaps": "^3.25.35",
    "@types/jasmine": "^2.5.35",
    "@types/jquery": "^2.0.33",
    "@types/lodash": "^4.14.37",
    "@types/node": "^6.0.45",
    "@types/requirejs": "^2.1.28",

在我的package.json中为“devdependencies”,我有这些

frozenset

我也安装了@ types / requirejs ......但是这个错误不会消失。 我有什么遗漏或添加错误吗?

我正在使用webpack 2.1.0.beta.25来处理我的应用程序。

1 个答案:

答案 0 :(得分:4)

根据tsconfig.jsontypeRoots改为types,将compilerOptions { "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false, "types": [ "core-js", "jasmine", "node", "lodash", "jquery", "requirejs", "angular", "googlemaps" ], "typeRoots": [ "./node_modules/@types", "./src/custom-typings.d.ts" ] } } 属性改为If typesRoots is specified, only packages under typeRoots will be included

typesRoots

同时选中documentation,其中typesRoots代表C#,请先删除public static string EncodePassword(string password) { var provider = new SHA256CryptoServiceProvider(); var encoding = new UnicodeEncoding(); return Convert.ToBase64String(provider.ComputeHash(encoding.GetBytes(password))); } 或在{{1}}属性设置中进行更改。