I've installed TS and the node typings globally:
PS C:\Projects\Test> npm list --global --depth=0
C:\Users\Jan\AppData\Roaming\npm
+-- @types/node@7.0.5
+-- tslint@4.4.2
`-- typescript@2.2.1
Then I've created a file test.ts
import fs = require("fs");
let text = fs.readFileSync("myFile.txt");
console.log(text);
Runnning tsc results in
PS C:\Projects\Test> tsc .\test.ts
test.ts(1,21): error TS2307: Cannot find module 'fs'.
Do I miss something obvious?
Thanks!
You should install @types
locally to your project.
npm install @types/node --save-dev
TypeScript will not find globally installed types as definition files.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.