简体   繁体   English

TypeError:无法读取tsc.js中未定义的属性“ length”

[英]TypeError: Cannot read property 'length' of undefined in tsc.js

I have created a nodejs api project using typescript. 我已经使用typescript创建了一个nodejs api项目。 But I am not able to start it. 但是我无法启动它。 This is the command I am running 这是我正在运行的命令

npm start

This is the output of this command 这是此命令的输出

> project1@1.0.0 prestart D:\Workspace
> tsc

D:\Workspace\node_modules\typescript\lib\tsc.js:9921
                for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) {
                                                                     ^

TypeError: Cannot read property 'length' of undefined
    at Object.forEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:9921:70)
    at setParentPointers (D:\Workspace\node_modules\typescript\lib\tsc.js:17392:12)
    at D:\Workspace\node_modules\typescript\lib\tsc.js:17392:64
    at visitNode (D:\Workspace\node_modules\typescript\lib\tsc.js:9533:24)
    at Object.forEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:9918:25)
    at setParentPointers (D:\Workspace\node_modules\typescript\lib\tsc.js:17392:12)
    at D:\Workspace\node_modules\typescript\lib\tsc.js:17392:64
    at visitNodes (D:\Workspace\node_modules\typescript\lib\tsc.js:9542:30)
    at Object.forEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:9891:24)
    at setParentPointers (D:\Workspace\node_modules\typescript\lib\tsc.js:17392:12)
    at bindChildrenWorker (D:\Workspace\node_modules\typescript\lib\tsc.js:15178:25)
    at bindChildren (D:\Workspace\node_modules\typescript\lib\tsc.js:15129:17)
    at bindContainer (D:\Workspace\node_modules\typescript\lib\tsc.js:15122:17)
    at bind (D:\Workspace\node_modules\typescript\lib\tsc.js:16214:21)
    at Object.forEach (D:\Workspace\node_modules\typescript\lib\tsc.js:275:30)
    at bindEach (D:\Workspace\node_modules\typescript\lib\tsc.js:15149:20)
    at visitNodes (D:\Workspace\node_modules\typescript\lib\tsc.js:9538:24)
    at Object.forEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:9707:24)
    at bindEachChild (D:\Workspace\node_modules\typescript\lib\tsc.js:15165:16)
    at bindChildrenWorker (D:\Workspace\node_modules\typescript\lib\tsc.js:15254:21)
    at bindChildren (D:\Workspace\node_modules\typescript\lib\tsc.js:15129:17)
    at bindContainer (D:\Workspace\node_modules\typescript\lib\tsc.js:15093:17)
    at bind (D:\Workspace\node_modules\typescript\lib\tsc.js:16214:21)
    at bindSourceFile (D:\Workspace\node_modules\typescript\lib\tsc.js:14851:17)
    at Object.bindSourceFile (D:\Workspace\node_modules\typescript\lib\tsc.js:14809:9)
    at initializeTypeChecker (D:\Workspace\node_modules\typescript\lib\tsc.js:36496:20)
    at Object.createTypeChecker (D:\Workspace\node_modules\typescript\lib\tsc.js:18543:9)
    at getDiagnosticsProducingTypeChecker (D:\Workspace\node_modules\typescript\lib\tsc.js:56042:93)
    at Object.getGlobalDiagnostics (D:\Workspace\node_modules\typescript\lib\tsc.js:56370:53)
    at compileProgram (D:\Workspace\node_modules\typescript\lib\tsc.js:59092:78)
    at compile (D:\Workspace\node_modules\typescript\lib\tsc.js:59051:26)
    at performCompilation (D:\Workspace\node_modules\typescript\lib\tsc.js:58940:33)
    at Object.executeCommandLine (D:\Workspace\node_modules\typescript\lib\tsc.js:58883:9)
    at Object.<anonymous> (D:\Workspace\node_modules\typescript\lib\tsc.js:59241:4)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\Workspace\node_modules\typescript\bin\tsc:2:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

npm ERR! Windows_NT 10.0.14393
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.5
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! project1@1.0.0 prestart: `tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project1@1.0.0 prestart script 'tsc'.
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 project1 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs project1
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls project1
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\Workspace\npm-debug.log

and my package.json 和我的package.json

{
  "name": "project1",
  "version": "1.0.0",
  "description": "Project 1",
  "main": "index.js",
  "scripts": {
    "prestart": "tsc",
    "start": "concurrently \"tsc --watch \" \"nodemon server.js startServer\"",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "license": "ISC",
  "dependencies": {
    "@types/es6-promise": "0.0.32",
    "body-parser": "^1.16.0",
    "es6-map": "^0.1.5",
    "giuseppe": "^1.2.0",
    "make-runnable": "^1.0.7",
    "request": "^2.79.0",
    "request-promise": "^4.1.1",
    "typescript": "^2.1.4"
  },
  "devDependencies": {
    "@types/chai": "^3.4.34",
    "concurrently": "^3.1.0",
    "nodemon": "^1.11.0"
  }
}

I have tried deleting node_modules folder and clearing cache using 我试着删除node_modules文件夹并使用清除缓存

npm cache clear

and then installing it again using 然后使用重新安装

npm install

but fail to start? 但是无法启动? what could be the issue? 可能是什么问题?

The issue was with typescript itself. 问题出在打字稿本身。 Here is the issue raised on Github 这是在Github上提出的问题

https://github.com/Microsoft/TypeScript/issues/18301 https://github.com/Microsoft/TypeScript/issues/18301

but now the issue has been fixed. 但现在问题已解决。

Just update typescript module 只需更新打字稿模块

npm update typescript --save

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:无法读取Node.js中未定义的属性“ length” - TypeError: Cannot read property 'length' of undefined in Node.js TypeError无法读取节点js中未定义的属性&#39;length&#39; - TypeError cannot read property 'length' of undefined in node js Node.js - TypeError:无法读取未定义的属性“长度” - Node.js - TypeError: Cannot read property 'length' of undefined 未捕获的类型错误:无法读取 node.js 上未定义的属性“长度” - Uncaught TypeError: Cannot read property 'length' of undefined on node.js TypeError:无法读取未定义的node.js的属性“ length” - TypeError: Cannot read property 'length' of undefined node.js 打字稿错误 -- 错误:找不到模块“打字稿/tsc.js” - Typescript error -- Error: Cannot find module 'typescript/tsc.js' opencv-TypeError:无法读取未定义的属性“长度” - opencv - TypeError: Cannot read property 'length' of undefined TypeError:无法读取未定义的属性“ length”? - TypeError: Cannot read property 'length' of undefined? UnhandledPromiseRejectionWarning: TypeError: 无法读取未定义的属性“长度” - UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined TypeError:无法读取cryptoJS中未定义的属性“长度” - TypeError: Cannot read property 'length' of undefined in cryptoJS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM