Skip to content

Commit e2a17cb

Browse files
authored
Update nodejs.md
1 parent bd556b7 commit e2a17cb

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

docs/quick/nodejs.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,14 @@ TypeScript has had *first class* support for NodeJS since inception. Here's how
77
1. Add TypeScript (`npm install typescript --save-dev`)
88
1. Add `node.d.ts` (`npm install @types/node --save-dev`)
99
1. Init a `tsconfig.json` for TypeScript options (`node ./node_modules/typescript/lib/tsc --init`)
10+
1. Make sure you have `compilerOptions.module:commonjs` in your tsconfig.json
1011

1112
That's it! Fire up your IDE (e.g. `alm -o`) and play around. Now you can use all the built in node modules (e.g. `import fs = require('fs');`) with all the safety and developer ergonomics of TypeScript!
1213

1314
## Bonus: Live compile + run
1415
* Add `ts-node` which we will use for live compile + run in node (`npm install ts-node --save-dev`)
1516
* Add `nodemon` which will invoke `ts-node` whenever a file is changed (`npm install nodemon --save-dev`)
1617

17-
Let's explicitly tell `ts-node` where to look for types by editing `tsconfig.json`:
18-
19-
```json
20-
{
21-
"compilerOptions": {
22-
...
23-
"typeRoots": ["node_modules/@types"]
24-
}
25-
}
26-
```
27-
2818
Now just add a `script` target to your `package.json` based on your application entry e.g. assuming its `index.ts`:
2919

3020
```json

0 commit comments

Comments
 (0)