tsc-silent
tsc-silent copied to clipboard
Error: Cannot find module 'typescript'
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?
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 ...
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:
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
.