Skip to content

Cannot read property 'resolvedModules' of undefined when running tscc with Yarn 2 #464

@Ririshi

Description

@Ririshi

When trying to run tscc on my Node project, I am getting the following error:

TypeError: Cannot read property 'resolvedModules' of undefined
    at TypescriptDependencyGraph.walk (<project_folder>\.yarn\cache\@tscc-tscc-npm-0.6.3-0d17947750-0211229831.zip\node_modules\@tscc\tscc\dist\graph\TypescriptDependencyGraph.js:81:16)
    at TypescriptDependencyGraph.walk (<project_folder>\.yarn\cache\@tscc-tscc-npm-0.6.3-0d17947750-0211229831.zip\node_modules\@tscc\tscc\dist\graph\TypescriptDependencyGraph.js:83:22)
    at TypescriptDependencyGraph.walk (<project_folder>\.yarn\cache\@tscc-tscc-npm-0.6.3-0d17947750-0211229831.zip\node_modules\@tscc\tscc\dist\graph\TypescriptDependencyGraph.js:83:22)
    at TypescriptDependencyGraph.addRootFile (<project_folder>\.yarn\cache\@tscc-tscc-npm-0.6.3-0d17947750-0211229831.zip\node_modules\@tscc\tscc\dist\graph\TypescriptDependencyGraph.js:112:14)
    at <project_folder>\.yarn\cache\@tscc-tscc-npm-0.6.3-0d17947750-0211229831.zip\node_modules\@tscc\tscc\dist\tscc.js:45:72
    at Array.forEach (<anonymous>)
    at Object.tscc [as default] (<project_folder>\.yarn\cache\@tscc-tscc-npm-0.6.3-0d17947750-0211229831.zip\node_modules\@tscc\tscc\dist\tscc.js:45:38)
    at main (<project_folder>\.yarn\cache\@tscc-tscc-npm-0.6.3-0d17947750-0211229831.zip\node_modules\@tscc\tscc\dist\main.js:27:25)
    at Object.<anonymous> (<project_folder>\.yarn\cache\@tscc-tscc-npm-0.6.3-0d17947750-0211229831.zip\node_modules\@tscc\tscc\dist\main.js:139:5)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)

I've attached some info I think is relevant. I am using Yarn 2 (as you can probably see from the error trace). I am calling tscc using the yarn build command, defined in package.json below.

tsconfig.json:

{
  "compilerOptions": {
    "importHelpers": true,
    "lib": ["ES2020"],
    "module": "CommonJS",
    "moduleResolution": "node",
    "noImplicitAny": false,
    "preserveConstEnums": true,
    "resolveJsonModule": true,
    "sourceMap": true,
    "target": "ES6",
    "typeRoots": ["./node_modules/@types", "./src/typings"]
  },
  "include": ["src/**/*"]
}

tscc.spec.json:

{
  "modules": {
    "out": "src/main.ts"
  },
  "external": {
    "ajv": "AJV",
    "dayjs": "DayJS",
    "deepmerge": "DeepMerge",
    "discord.js": "DiscordJS",
    "glob": "Glob",
    "type-fest": "TypeFest"
  },
  "prefix": "dist/"
}

Relevant info in package.json:

{
  "scripts": {
    "build": "tscc --spec tscc.spec.json",
  },
  "dependencies": {
    "ajv": "^7.0.4",
    "dayjs": "^1.10.3",
    "deepmerge": "^4.2.2",
    "discord.js": "^12.5.1",
    "glob": "^7.1.6",
    "type-fest": "^0.20.2"
  },
  "devDependencies": {
    "@tscc/tscc": "^0.6.3",
    "@types/glob": "^7.1.3",
    "@types/node": "^14.14.16",
    "@typescript-eslint/eslint-plugin": "^4.11.1",
    "@typescript-eslint/parser": "^4.11.1",
    "eslint": "^7.16.0",
    "eslint-config-prettier": "^7.1.0",
    "eslint-plugin-prettier": "^3.3.0",
    "node-schedule": "^1.3.2",
    "nodemon": "^2.0.6",
    "prettier": "^2.2.1",
    "ts-node": "^9.1.1",
    "tslib": "^2.1.0",
    "typescript": "^4.0",
    "typescript-json-schema": "^0.48.0"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions