我不能将任何类型的@ type / node用于打字稿3.2
我的tsconfig:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"skipLibCheck": true,
"suppressImplicitAnyIndexErrors": true,
"outDir": "target/www/app",
"lib": ["es7", "dom"],
"baseUrl": "./",
"paths": {
"app/*": ["src/app/*"]
},
"types": ["node"],
"importHelpers": true,
"allowJs": true
}
}
打字稿版本:3.2.2 @ type / node的版本:11.13.5
我收到此错误消息:
错误TS2580:找不到名称“进程”。您需要安装类型吗 节点的定义?尝试
npm i @types/node
,然后将node
添加到 tsconfig中的“类型”字段。
我理解该错误,但没有找到解决方法。
更新:
npm ls --depth=0
+-- @angular-devkit/build-angular@0.13.8
+-- @angular/animations@7.2.13
+-- @angular/cli@7.3.8
+-- @angular/common@7.2.13
+-- @angular/compiler@7.2.13
+-- @angular/compiler-cli@7.2.13
+-- @angular/core@7.2.13
+-- @angular/forms@7.2.13
+-- @angular/language-service@7.2.13
+-- @angular/platform-browser@7.2.13
+-- @angular/platform-browser-dynamic@7.2.13
+-- UNMET PEER DEPENDENCY @angular/platform-server@^7.1.4
+-- @angular/router@7.2.13
+-- @fortawesome/angular-fontawesome@0.3.0
+-- @fortawesome/fontawesome-svg-core@1.2.17
+-- @fortawesome/free-solid-svg-icons@5.8.1
+-- @ng-bootstrap/ng-bootstrap@4.1.1
+-- @nguniversal/express-engine@7.1.1
+-- @ngx-translate/core@11.0.1
+-- @ngx-translate/http-loader@4.0.0
+-- @types/jasmine@2.8.16
+-- @types/jasminewd2@2.0.6
+-- @types/node@11.13.5
+-- @types/webpack-env@1.13.9
+-- bootstrap@4.3.1
+-- codelyzer@4.5.0
+-- core-js@2.6.5
+-- jasmine-core@2.99.1
+-- jasmine-spec-reporter@4.2.1
+-- UNMET PEER DEPENDENCY jquery@1.9.1 - 3
+-- karma@4.0.1
+-- karma-chrome-launcher@2.2.0
+-- karma-coverage-istanbul-reporter@2.0.5
+-- karma-jasmine@1.1.2
+-- karma-jasmine-html-reporter@0.2.2
+-- moment@2.24.0
+-- ng-jhipster@0.9.3
+-- ngx-build-plus@7.8.1
+-- ngx-cookie@4.1.2
+-- ngx-infinite-scroll@7.1.0
+-- ngx-ui-switch@8.0.1
+-- ngx-webstorage@3.0.2
+-- UNMET PEER DEPENDENCY popper.js@^1.14.7
+-- protractor@5.4.2
+-- rxjs@6.3.3
+-- ts-node@7.0.1
+-- tslib@1.9.3
+-- tslint@5.11.0
+-- typescript@3.2.4
`-- zone.js@0.8.29
npm ERR! peer dep missing: @angular/platform-server@^7.1.4, required by @nguniversal/express-engine@7.1.1
npm ERR! peer dep missing: jquery@1.9.1 - 3, required by bootstrap@4.3.1
npm ERR! peer dep missing: popper.js@^1.14.7, required by bootstrap@4.3.1
npm ERR! missing: mkdirp@0.5.1, required by node-pre-gyp@0.12.0
npm ERR! missing: minimist@0.0.8, required by mkdirp@0.5.1
npm ERR! missing: minimatch@3.0.4, required by ignore-walk@3.0.1
npm ERR! missing: brace-expansion@1.1.11, required by minimatch@3.0.4
npm ERR! missing: balanced-match@1.0.0, required by brace-expansion@1.1.11
npm ERR! missing: concat-map@0.0.1, required by brace-expansion@1.1.11
npm ERR! missing: console-control-strings@1.1.0, required by npmlog@4.1.2
npm ERR! missing: inherits@2.0.3, required by readable-stream@2.3.6
npm ERR! missing: safe-buffer@5.1.2, required by readable-stream@2.3.6
npm ERR! missing: safe-buffer@5.1.2, required by string_decoder@1.1.1
npm ERR! missing: console-control-strings@1.1.0, required by gauge@2.7.4
npm ERR! missing: string-width@1.0.2, required by gauge@2.7.4
npm ERR! missing: strip-ansi@3.0.1, required by gauge@2.7.4
npm ERR! missing: code-point-at@1.1.0, required by string-width@1.0.2
npm ERR! missing: is-fullwidth-code-point@1.0.0, required by string-width@1.0.2
npm ERR! missing: strip-ansi@3.0.1, required by string-width@1.0.2
npm ERR! missing: number-is-nan@1.0.1, required by is-fullwidth-code-point@1.0.0
npm ERR! missing: ansi-regex@2.1.1, required by strip-ansi@3.0.1
npm ERR! missing: string-width@1.0.2, required by wide-align@1.1.3
npm ERR! missing: inherits@2.0.3, required by glob@7.1.3
npm ERR! missing: minimatch@3.0.4, required by glob@7.1.3
npm ERR! missing: once@1.4.0, required by glob@7.1.3
npm ERR! missing: once@1.4.0, required by inflight@1.0.6
npm ERR! missing: wrappy@1.0.2, required by inflight@1.0.6
npm ERR! missing: wrappy@1.0.2, required by once@1.4.0
npm ERR! missing: minipass@2.3.5, required by tar@4.4.8
npm ERR! missing: mkdirp@0.5.1, required by tar@4.4.8
npm ERR! missing: safe-buffer@5.1.2, required by tar@4.4.8
npm ERR! missing: yallist@3.0.3, required by tar@4.4.8
npm ERR! missing: minipass@2.3.5, required by fs-minipass@1.2.5
npm ERR! missing: safe-buffer@5.1.2, required by minipass@2.3.5
npm ERR! missing: yallist@3.0.3, required by minipass@2.3.5
npm ERR! missing: minipass@2.3.5, required by minizlib@1.2.1
答案 0 :(得分:0)
我的问题是在tsconfig.app.json中使用tsconfig.json扩展了另一个文件。
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
类型被覆盖:
"types": []
删除此行可解决此问题。