Skip to content

Cannot read property 'length' of undefined in parseConfigFileTextToJson #17138

@ghost

Description

I was trying to reproduce #15632 and created a simple JS project with:
jsconfig.json

{
    "compilerOptions": {
        "checkJs": true
    }
}

try.js

// @ts-check

var util = require("util");
util.inspect();

I got this error in the typings installer logs:

Global cache location '/home/andy/.cache/typescript/2.5', safe file path '/home/andy/.nvm/versions/node/v8.0.0/lib/node_modules/typescript/lib/typingSafeList.json'
Processing cache location '/home/andy/.cache/typescript/2.5'
Trying to find '/home/andy/.cache/typescript/2.5/package.json'...
Loaded content of '/home/andy/.cache/typescript/2.5/package.json': {"dependencies":{"types-registry":"^0.1.297"},"devDependencies":{"@types/node":"^7.0.31"}}
Adding entry into typings cache: 'node' => '/home/andy/.cache/typescript/2.5/node_modules/@types/node/index.d.ts'
Finished processing cache location '/home/andy/.cache/typescript/2.5'
Process id: 14240
NPM location: npm (explicit '--npmLocation' not  provided)
Npm config file: /home/andy/.cache/typescript/2.5/package.json
Updating types-registry npm package...
Updated types-registry npm package
Got install request {"projectName":"/home/andy/sample/js2/jsconfig.json","fileNames":["/home/andy/.nvm/versions/node/v8.0.0/lib/node_modules/typescript/lib/lib.d.ts","/home/andy/sample/js2/try.js"],"compilerOptions":{"allowJs":true,"maxNodeModuleJsDepth":2,"allowSyntheticDefaultImports":true,"skipLibCheck":true,"checkJs":true,"configFilePath":"/home/andy/sample/js2/jsconfig.json","allowNonTsExtensions":true},"typeAcquisition":{"enable":true,"include":[],"exclude":[]},"unresolvedImports":["util"],"projectRootPath":"/home/andy/sample/js2","kind":"discover"}
Unhandled exception: TypeError: Cannot read property 'length' of undefined at TypeError: Cannot read property 'length' of undefined
    at createSourceFile (/home/andy/.nvm/versions/node/v8.0.0/lib/node_modules/typescript/lib/typingsInstaller.js:10165:74)
    at Object.parseJsonText (/home/andy/.nvm/versions/node/v8.0.0/lib/node_modules/typescript/lib/typingsInstaller.js:10056:26)
    at Object.parseJsonText (/home/andy/.nvm/versions/node/v8.0.0/lib/node_modules/typescript/lib/typingsInstaller.js:9993:23)
    at parseConfigFileTextToJson (/home/andy/.nvm/versions/node/v8.0.0/lib/node_modules/typescript/lib/typingsInstaller.js:15722:33)
    at Object.readConfigFile (/home/andy/.nvm/versions/node/v8.0.0/lib/node_modules/typescript/lib/typingsInstaller.js:15718:16)
    at Object.discoverTypings (/home/andy/.nvm/versions/node/v8.0.0/lib/node_modules/typescript/lib/typingsInstaller.js:16638:33)
    at NodeTypingsInstaller.TypingsInstaller.install (/home/andy/.nvm/versions/node/v8.0.0/lib/node_modules/typescript/lib/typingsInstaller.js:17687:61)
    at process.<anonymous> (/home/andy/.nvm/versions/node/v8.0.0/lib/node_modules/typescript/lib/typingsInstaller.js:18054:39)
    at emitTwo (events.js:106:13)
    at process.emit (events.js:191:7)

CC @sheetalkamat

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions