【问题标题】:Cannot find namespace 'NodeJS' also with types node也找不到类型节点的命名空间“NodeJS”
【发布时间】:2020-12-28 16:07:48
【问题描述】:

我的网络应用程序中出现此错误

ERROR in node_modules/zone.js/dist/zone.js.d.ts:600:21 - error TS2503: Cannot find namespace 'NodeJS'.

600 declare var global: NodeJS.Global;

正如您在下面看到的,我已经添加了 types": ["node"] 属性,但它仍然无法正常工作

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "types": ["node"],
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "es6",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  }
}

我真的不知道如何解决它。应用程序第一次开始获取Cannot GET /,然后在保存任何文件后,它可以工作,但仍然出现 NodeJS 错误。谢谢

【问题讨论】:

    标签: node.js angular typescript node-modules


    【解决方案1】:

    对于那些有这种问题的人,我解决了更新 zone.js 的版本"zone.js": "^0.11.1"

    【讨论】:

      猜你喜欢
      • 2017-01-11
      • 1970-01-01
      • 1970-01-01
      • 2013-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-12
      • 2011-05-13
      相关资源
      最近更新 更多