question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Can't find module 'TypeScript'

See original GitHub issue
Overview of the issue

Can’t generate documentation, got error:

$ compodoc -p ./tsconfig.json
module.js:471
    throw err;
    ^

Error: Cannot find module 'typescript'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/user/Projects/test-proj/node_modules/@compodoc/ngd-core/dist/lang/utilities.js:2:10)
    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)

I have an typescript module installed (tried using yarn and npm) locally.

Operating System, Node.js, npm, compodoc version(s)
  • Compodoc: 1.0.1
  • Node: v6.10.12
  • OS: macOS Sierra
Angular configuration, a package.json file in the root folder

Package.json:

{
  "name": "...",
  "description": "...",
  "version": "...",
  "license": "proprietary",
  "private": true,
  "scripts": {
    "ng": "ng",
    "start": "ng serve --port 8080",
    "start:aot": "ng serve --aot --port 8080",
    "start:local": "npm run build:dev && http-server ./dist",
    "build:prod": "ng build --prod --env=prod --aot",
    "build:dev": "ng build --dev --env=dev --aot",
    "build": "npm run build:prod",
    "deploy": "npm run lint && npm run test && npm run build:prod",
    "test": "ng test --single-run --browser PhantomJS",
    "test:chrome": "ng test --browser Chrome",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "doc": "npm run doc:serve",
    "doc:generate": "compodoc -p ./tsconfig.json",
    "doc:serve": "compodoc -s -r 8090",
    "doc:watch": "compodoc -p ./tsconfig.json -w -s -r 8090",
    "config": "npm run config:init",
    "config:pom": "node private/setup.js --pom",
    "config:init": "node private/setup.js --init",
    "config:flush": "node private/setup.js --import -f",
    "config:check": "node private/setup.js --check",
    "config:create": "node private/setup.js --import",
    "postinstall": "npm run config:create"
  },
  "dependencies": {
    "@angular/common": "^4.0.1",
    "@angular/compiler": "^4.0.1",
    "@angular/core": "^4.0.1",
    "@angular/forms": "^4.0.1",
    "@angular/http": "^4.0.1",
    "@angular/platform-browser": "^4.0.1",
    "@angular/platform-browser-dynamic": "^4.0.1",
    "@angular/router": "^4.0.1",
    "@compodoc/compodoc": "^1.0.1",
    "@types/file-saver": "^0.0.1",
    "angular-linky": "^1.2.2",
    "chart.js": "^2.6.0",
    "compodoc": "^0.0.41",
    "core-js": "^2.4.1",
    "es6-shim": "^0.35.3",
    "file-saver": "^1.3.3",
    "fuse-js-latest": "^2.6.2",
    "http-server": "^0.10.0",
    "intl": "^1.2.5",
    "jquery": "^3.2.1",
    "karma-phantomjs-launcher": "^1.0.4",
    "lodash": "^4.17.4",
    "moment": "^2.18.1",
    "ng2-charts": "^1.6.0",
    "ng2-toasty": "^2.5.0",
    "ng2-validation": "^4.2.0",
    "ngx-bootstrap": "next",
    "node-sass": "^4.5.3",
    "normalize-url": "^1.9.1",
    "phantomjs-prebuilt": "^2.1.14",
    "reflect-metadata": "^0.1.3",
    "rxjs": "^5.0.1",
    "zone.js": "^0.8.5"
  },
  "devDependencies": {
    "@angular/cli": "1.0.3",
    "@angular/compiler-cli": "^4.0.1",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.2.0"
  }
}

Compodoc installed globally or locally ?

Locally

Motivation for or Use Case
Reproduce the error
  • Install dependencies from package.json
  • Try to generate docs
Related issues
Suggest a Fix

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vogloblinskycommented, Sep 14, 2017

Cool ! 👍 Happy documentation 😄

0reactions
lock[bot]commented, Oct 1, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem. Why locking ? Having issues with the most up-to-date context.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module 'X' Error in TypeScript | bobbyhadz
The "Cannot find module or its corresponding type declarations" error occurs when TypeScript cannot locate a third-party or local module in our project....
Read more >
How to fix Cannot find module 'typescript' in Angular 4?
3. Hi @Sajeetharan I have installed it globall using your command above. · 1. try to uninstall angular-cli globally, run npm cache clean...
Read more >
Fixing The "Cannot Find Module" Error In TypeScript
In this article, I explain how to fix "cannot find module" in TypeScript. Install the package. Re-install the dependencies.
Read more >
Cannot find module 'typescript' · Issue #707 - GitHub
when I execute: $ npx ts-node, it throwing Cannot find module 'typescript' how ... I solve this problem by reinstalling typescript globally
Read more >
Error: Cannot find module 'typescript' - Sonar Community
Error: Cannot find module 'typescript' · (Recommended) Running npm install before starting an analysis on each of your TS project to make ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found