#How to generate tsconfig file without installing typescript? With npx?

8 messages · Page 1 of 1 (latest)

edgy hill
#

I tried running
npx tsc --init which generated tsconfig file
However as tsc getting deprecated, when I tried npx typescript --init failed with
npm ERR! could not determine executable to run

raven brook
#

I think you might have misunderstood something here, tsc itself is not deprecated, only the tsc npm package, so you dont have to install both tsc and typescript package.
Just install typescript, then you can use tsc

edgy hill
#

So there is no way to generate tsc config with npx?

#

Seems official docs recommending deprecating package

rustic moon
#

@edgy hill @raven brook thing is,

the tsc npm package has been deprecated for ages
the package you need to install/use for typescript is called typescript

but the executable provided by the typescript package is called tsc

so, since the name of the executable is different from the name of the package, you need to use the -p option when using npx
it allows the specify what package to run the command against

final result is npx -p typescript tsc --init

https://docs.npmjs.com/cli/v9/commands/npx

The -p argument is a shorthand for --parseable in npm, but shorthand for --package in npx. This is maintained, but only for the npx executable.

rustic moon
edgy hill