Typescript错误:在运行ng-serve时无法读取未定义的属性“length”。

4

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

ng serve 无法读取未定义的 'length' 属性 类型错误: 无法读取未定义的 'length' 属性 在 createSourceFile (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\typescript\lib\typescript.js:8980:109) 在 parseSourceFileWorker (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\typescript\lib\typescript.js:8940:26) 在 Object.parseSourceFile (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\typescript\lib\typescript.js:8899:26) 在 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) 在 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 在 process._tickCallback (internal/process/next_tick.js:103:7)


嗨,Elluru,这看起来像是与你的代码无关的错误。尝试在谷歌上搜索“Cannot read property 'length' of undefined at createSourceFile”。 - user6307701
include your code - Beginner
1个回答

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 */

如果未找到/无法读取源文件夹或未找到源文件,则文件长度未定义。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接