src/app/value/value.component.ts(4,15) 中的错误:错误 TS2580:找不到名称'module'



当我在Visual Studio Code>终端中做时:ng serve我收到该错误:

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2019-04-11T08:13:05.077Z
Time: 3917ms
chunk {main} main.js, main.js.map (main) 1.93 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 93.1 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.3 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 327 kB [initial] [rendered]
ERROR in src/app/value/value.component.ts(4,15): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node`.
i 「wdm」: Failed to compile.

我已经在堆栈上查看了类似的问题,但它对我没有帮助。

我需要编译此代码,因为我想打开浏览器:http://localhost:4200/但它不起作用,但出现错误:无法获取

我也遇到了这个问题。有几件事我必须做。

在 tsconfig.json 中更改模块

"module": "commonjs"

"安装类型"节点

npm i @types/node

在tsconfig.json和tsconfig.app.json中添加

"types": [
  "node"
]

希望这有帮助

相关内容

最新更新