I'm new programmer on angular2. I have problem when compile with angular cli.
I generate angular 2 project by angular cli.
I'm trying to use debuglog
module on node_modules/@types/node
by import module like this: import {debuglog} from "util";
I use Webstorm IDE for develop and the ide do not warning or error with my import. I checked and found debuglog
module in path: myproject/node_modules/@types/node/index.d.ts
.
What's wrong in my code? Have any suggestion for fix it?
Project on Github: https://github.com/sinhpn92/angular2-example-types-node
Version of environments:
@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
This solved the issue for me - https://github.com/angular/angular-cli/wiki/stories-third-party-lib
"types": [
"node"
]
in tsconfig.app.json.
Noticed that your tsconfig.json lacks the following entry in compilerOptions
:
compilerOptions{
//......,
"typeRoots": [
"node_modules/@types"
]
}
Try adding it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With