在angular2应用程序中运行ng serve时收到错误“无法读取未定义的属性"长度"的错误" [英] getting error 'Cannot read property 'length' of undefined' while running ng serve in angular2 application

查看:178
本文介绍了在angular2应用程序中运行ng serve时收到错误“无法读取未定义的属性"长度"的错误"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用angular-cli命令ng-serve运行angular2应用程序时,出现以下问题

while running angular2 application using angular-cli command ng-serve i am getting the following issue

dashboard@0.0.0开始C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \ dashboard ng服务

dashboard@0.0.0 start C:\Users\padmavathi\Downloads\phototype-development\web\dashboard ng serve

Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at 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)
    at new TypeScriptFileRefactor (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\@ngtools\webpack\src\refactor.js:25:35)
    at Object.resolveEntryModuleFromMain (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\@ngtools\webpack\src\entry_resolver.js:108:18)
    at AotPlugin._setupOptions (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\@ngtools\webpack\src\plugin.js:129:58)
    at new 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)
    at new NgCliWebpackConfig (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\angular-cli\models\webpack-config.js:23:42)
    at Class.run (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\angular-cli\tasks\serve-webpack.js:20:22)
    at 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)

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! dashboard@0.0.0 start: `ng serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dashboard@0.0.0 start script 'ng serve'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the dashboard package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ng serve
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs dashboard
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls dashboard
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\npm-debug.log.

请帮助我解决此问题. 提前致谢.

please help me to resolve this issue. thanks in advance.

推荐答案

出现了同样的问题.

我添加了

console.log("createSourceFile " + fileName);

位于\node_modules\typescript\lib\typescript.js

再次运行ng build,记录了所有文件. 我设法查看丢失的文件并进行处理.

running ng build again, logged all files. I was managed to see what file is missing, and handle it.

这篇关于在angular2应用程序中运行ng serve时收到错误“无法读取未定义的属性"长度"的错误"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆