ng2-material:错误 TS2304:找不到名称 'process'
ng2-material: error TS2304: Cannot find name 'process'
将我的项目更新到 Justin DuJardin's ng2-material 版本 0.3.8
后(基于 Angular 2.0.0-beta.14
),编译失败并出现以下错误:
Using tsc v1.8.0
ng2-material/core/util/viewport.ts(62,12): error TS2304: Cannot find name 'process'.
ng2-material/webpack_all.ts(1,1): error TS2304: Cannot find name 'module'.
ng2-material/webpack_all.ts(1,18): error TS2304: Cannot find name 'require'.
ng2-material/webpack_all.ts(2,1): error TS2304: Cannot find name 'require'.
ng2-material/webpack_all.ts(3,1): error TS2304: Cannot find name 'require'.
ng2-material/webpack_styles.ts(1,1): error TS2304: Cannot find name 'require'.
ng2-material/webpack_styles.ts(2,1): error TS2304: Cannot find name 'require'.
>> 7 non-emit-preventing type warnings
>> Error: tsc return code: 2
Warning: Task "ts:source" failed. Use --force to continue.
安装 typings 没有解决编译问题:
npm install typings --save-dev --global
typings install --save --ambient
而不是安抚 TS 编译器,如对类似 SO 问题的几个答案所述,例如 and ,我更愿意找到潜在的问题并获得真正的解决方案,如果有的话一.
我的TS配置如下:
tsd.json
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"node/node.d.ts": {
"commit": "e0abafb1a6ff652f7ff967120e312d5c1916eaef"
},
"requirejs/require.d.ts": {
"commit": "e0abafb1a6ff652f7ff967120e312d5c1916eaef"
},
"jasmine/jasmine.d.ts": {
"commit": "e0abafb1a6ff652f7ff967120e312d5c1916eaef"
}
}
}
tsconfig.json
"files": [
"node_modules/angular2/typings/browser.d.ts",
"dist/ng2-material.d.ts",
"ng2-material/all.ts",
"ng2-material/components/backdrop/backdrop.ts",
"ng2-material/components/button/button.ts",
...
关于如何找到此问题的根本原因并解决它的任何想法?
遗憾的是,我发现的唯一 "solution" 是前向声明解决方法:
declare function require(path: string) : any;
我将其添加到我的应用程序引导 TS 文件中。
将我的项目更新到 Justin DuJardin's ng2-material 版本 0.3.8
后(基于 Angular 2.0.0-beta.14
),编译失败并出现以下错误:
Using tsc v1.8.0
ng2-material/core/util/viewport.ts(62,12): error TS2304: Cannot find name 'process'.
ng2-material/webpack_all.ts(1,1): error TS2304: Cannot find name 'module'.
ng2-material/webpack_all.ts(1,18): error TS2304: Cannot find name 'require'.
ng2-material/webpack_all.ts(2,1): error TS2304: Cannot find name 'require'.
ng2-material/webpack_all.ts(3,1): error TS2304: Cannot find name 'require'.
ng2-material/webpack_styles.ts(1,1): error TS2304: Cannot find name 'require'.
ng2-material/webpack_styles.ts(2,1): error TS2304: Cannot find name 'require'.
>> 7 non-emit-preventing type warnings
>> Error: tsc return code: 2
Warning: Task "ts:source" failed. Use --force to continue.
安装 typings 没有解决编译问题:
npm install typings --save-dev --global
typings install --save --ambient
而不是安抚 TS 编译器,如对类似 SO 问题的几个答案所述,例如
我的TS配置如下:
tsd.json
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"node/node.d.ts": {
"commit": "e0abafb1a6ff652f7ff967120e312d5c1916eaef"
},
"requirejs/require.d.ts": {
"commit": "e0abafb1a6ff652f7ff967120e312d5c1916eaef"
},
"jasmine/jasmine.d.ts": {
"commit": "e0abafb1a6ff652f7ff967120e312d5c1916eaef"
}
}
}
tsconfig.json
"files": [
"node_modules/angular2/typings/browser.d.ts",
"dist/ng2-material.d.ts",
"ng2-material/all.ts",
"ng2-material/components/backdrop/backdrop.ts",
"ng2-material/components/button/button.ts",
...
关于如何找到此问题的根本原因并解决它的任何想法?
遗憾的是,我发现的唯一 "solution" 是前向声明解决方法:
declare function require(path: string) : any;
我将其添加到我的应用程序引导 TS 文件中。