当我在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.
我已经在stackoverlow上看到了类似的问题,但这并没有帮助我。
我需要编译此代码,因为我想打开浏览器:http://localhost:4200/,但是它不起作用,出现错误:无法获取
答案 0 :(得分:0)
我也遇到了这个问题。我必须做几件事。
在tsconfig.json中更改模块
"module": "commonjs"
安装类型节点
npm i @types/node
在tsconfig.json和tsconfig.app.json中都添加
"types": [
"node"
]
希望这会有所帮助