tsc-silent icon indicating copy to clipboard operation
tsc-silent copied to clipboard

Error: Cannot find module 'typescript'

Open anirudhagarwal365 opened this issue 4 years ago • 3 comments

I followed the instructions mentioned on readme and I am getting the following error -

internal/modules/cjs/loader.js:985
  throw err;
  ^

Error: Cannot find module 'typescript'
Require stack:
- /Users/****/.config/yarn/global/node_modules/tsc-silent/dist/tsc-silent.js
- /Users/****/.config/yarn/global/node_modules/tsc-silent/bin/tsc-silent
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at Function.Module._load (internal/modules/cjs/loader.js:864:27)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/Users/****/.config/yarn/global/node_modules/tsc-silent/dist/tsc-silent.js:35:23)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/****/.config/yarn/global/node_modules/tsc-silent/dist/tsc-silent.js',
    '/Users/****/.config/yarn/global/node_modules/tsc-silent/bin/tsc-silent'
  ]
}

I am using typescript dependency in my package.json with version - 3.8.3 Command that I trying to run - tsc-silent -p tsconfig.json

Where am I going wrong?

anirudhagarwal365 avatar Oct 27 '20 10:10 anirudhagarwal365

Given that little information about your setup, I'd suggest you implicitly passing --compiler flag.

In the most trivial case, the call would look:

tsc-silent --compiler ./node_modules/typescript/lib/typescript.js ...

pablobirukov avatar Oct 27 '20 16:10 pablobirukov

Same error here. I am using explicitly the flag --compiler.

tsc-silent -p ./tsconfig.json --suppress @ --compiler ./node_modules/typescript/lib/typescript.js

I am running the command in the root of my project where the tsconfig.json belongs.

The error: imagen

Lzok avatar Feb 23 '21 03:02 Lzok

I faced the same issue and specifying the --compiler ./node_modules/typescript/lib/typescript.js option did not change anything.

I don't know why it works but it looks like installing typescript globally solves the issue. You can do this by running the following command: npm install -g typescript.

Amatewasu avatar Mar 13 '23 12:03 Amatewasu