5

I cannot figure out how to make my 'tsc' command working:

tsc
module.js:472
    throw err;
    ^

Error: Cannot find module 'typescript/tsc.js'
    at Function.Module._resolveFilename (module.js:470:15)

My 'package.json' has:

"devDependencies": {
    "@types/node": "^14.11.2",
    "tslib": "^2.0.1",
    "typedoc": "^0.19.2",
    "typescript": "^4.0.3"
  }

And my 'tsconfig.json':

{
  "compilerOptions": {
    "target": "es6",
    "sourceMap": true,
    "declaration": true,
    "declarationDir": "dist/types",
    "strict": true,
    "noUnusedLocals": true,
    "lib": [
      "es2019"
    ]
  },
  "include": [
    "src"
  ]
}

No error during 'npm install'.

When I check up the 'node_modules' folder, typescript exists and the 'tsc.js' file exists within the 'typescript/lib' directory.

node --version: 12.18.4

npm --version: 6.14.6

system: Ubuntu 16.04 LTS

I have tried many of the solution proposed for a similar issue without success:

  • delete the node_modules folder and then run npm install again
  • try to reinstall manually: npm install typescript --save-dev
  • using: npm install typescript-tools --save-dev
  • ...

None of the above gets me any result. Thank you very much for your help.

2 Answers 2

4

For those who gets stuck with that, the command that should be run with your local tsc is:

npx tsc

Sign up to request clarification or add additional context in comments.

Comments

2

To make the tsc --version command working, try to install using npm install -g typescript command. It installs the typescript globally.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.