编译错误:找不到模块'util'
我是angular2上的新程序员。 我有问题时,与angularcli编译。
我通过angular度cli生成angular度2项目。 我试图通过导入模块像这样在node_modules/@types/node
上使用debuglog
模块: import {debuglog} from "util";
我使用Webstorm IDE进行开发,IDE不会警告或错误导入。 我检查并findpath中的debuglog
模块: myproject/node_modules/@types/node/index.d.ts
。
我的代码有什么问题? 有任何build议修复它?
Github上的项目: https : //github.com/sinhpn92/angular2-example-types-node
环境版本:
@angular/cli: 1.0.0-rc.1 node: 7.7.1 os: darwin x64 @angular/common: 2.4.9 @angular/compiler: 2.4.9 @angular/core: 2.4.9 @angular/forms: 2.4.9 @angular/http: 2.4.9 @angular/platform-browser: 2.4.9 @angular/platform-browser-dynamic: 2.4.9 @angular/router: 3.4.9 @angular/upgrade: 2.2.4 @angular/cli: 1.0.0-rc.1 @angular/compiler-cli: 2.4.9
这解决了我的问题 – https://github.com/angular/angular-cli/wiki/stories-third-party-lib
"types": [ "node" ]
在tsconfig.app.json中。
注意到你的tsconfig.json在compilerOptions
缺less以下条目:
compilerOptions{ //......, "typeRoots": [ "node_modules/@types" ] }
尝试添加它。
- 由于networking连接问题,量angular器安装失败
- 如何解决npm“UNMET PEER DEPENDENCY”
- 找不到“节点”的types定义文件
- 在Visual Studio 2015 for Angular2上启动一个项目
- 如何在Angular 2中进行正确的http post调用?
- 删除NG重复量angular器中的logging
- 当服务器将事件发送到特定客户端时,不要使用Angular2来运行socket.io-client(不同的angular2服务)
- Angular2错误self.parentView.context ..是未定义的
- 将令牌传递给我的Angular 4应用程序的优雅方式是什么?