打字稿错误:在运行ng-serve时无法读取未定义的属性“长度”

时间:2016-12-15 06:58:25

标签: node.js angular typescript angular-cli

padmavathi @ K1037 C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard

  

ng服务   无法读取未定义的属性“长度”   TypeError:无法读取未定义的属性“length”       在createSourceFile(C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard \ node_modules \ typescript \ lib \ typescript.js:8980:109)       at parseSourceFileWorker(C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard \ node_modules \ typescript \ lib \ typescript.js:8940:26)       at Object.parseSourceFile(C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard \ node_modules \ typescript \ lib \ typescript.js:8899:26)       at Object.createSourceFile(C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard \ node_modules \ typescript \ lib \ typescript.js:8727:29)       在新的TypeScriptFileRefactor(C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard \ node_modules \ @ngtools \ webpack \ src \ refactor.js:25:35)       在Object.resolveEntryModuleFromMain(C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard \ node_modules \ @ngtools \ webpack \ src \ entry_resolver.js:108:18)       在AotPlugin._setupOptions(C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard \ node_modules \ @ngtools \ webpack \ src \ plugin.js:129:58)       在新的AotPlugin(C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard \ node_modules \ @ngtools \ webpack \ src \ plugin.js:37:14)       at Object.exports.getWebpackNonAotConfigPartial(C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard \ node_modules \ angular-cli \ models \ webpack-build-typescript.js:20:13)       在新的NgCliWebpackConfig(C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard \ node_modules \ angular-cli \ models \ webpack-config.js:23:42)       在Class.run(C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard \ node_modules \ angular-cli \ tasks \ serve-webpack.js:20:22)       在C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard \ node_modules \ angular-cli \ commands \ serve.js:102:26       at process._tickCallback(internal / process / next_tick.js:103:7)

1 个答案:

答案 0 :(得分:1)

我有同样的错误。 事实证明我在angular-cli.json文件中犯了一个错误。

{
  "project": {
    "version": "1.0.0-beta.22-1",
    "name": "angular3"
  },
  "apps": [
    {
      "root": "src",/* This must point to your source file locations*/
      "outDir": "dist",/* your output folder */

如果找不到/可读源文件夹或找不到源文件,则文件长度未定义。