For some reason npx tsc --init
prints out the following error:
$ npx tsc --init
npx: installed 1 in 1.467s
error TS5023: Unknown compiler option 'init'.
I have installed the typescript
package with Yarn 2:
$ yarn add -D typescript
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 0.31s
➤ YN0000: ┌ Fetch step
➤ YN0013: │ typescript@npm:3.9.3 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ typescript@patch:typescript@npm%3A3.9.3#builtin<compat/typescript>::version=3.9.3&hash=8cac75 can't be found in the cache and will be fetched from the disk
➤ YN0000: └ Completed in 1.46s
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: Done in 1.95s
Can someone explain to me why tsc
does not recognize --init
and what i am doing wrong?
UPDATE:
As Daniel figured out, the problem is that npx
does not find or recognize the typescript
package installed with Yarn 2. The solution was to use yarn
instead: yarn tsc --init