Typescript @ types / node import fs失败

时间:2017-03-24 19:42:24

标签: node.js angular typescript

我正在尝试读取Typescripts中的文件。我正在使用@ types / node而不是typings。

没有编译错误。但是调试器中的fs显示为undefined。 我错过了什么?

test.ts

ListView

tsconfig.app.json

import * as fs from 'fs';
fs.readFile('../some.xml', 'utf8', function (err, data) {
    if (err) {
        return console.log(err);
    }
    console.log(data);
});

的package.json

{
  "compilerOptions": {
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2016",
      "dom"
    ],
    "outDir": "./dist",
    "target": "es5",
    "module": "es2015",
    "baseUrl": "",
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": [
      "node"
    ]
  },
  "filesGlob": [
    "./node_modules/@types//.d.ts"
  ],
  "exclude": [
    "test-helpers",
    "test.ts",
    "**/*.spec.ts"
  ],
  "angularCompilerOptions": {
    "genDir": "./locale"
  }
}

0 个答案:

没有答案