简体   繁体   中英

How does the TypeScript NPM package register itself as tsc?

I want to make a package that has one or more aliases. I am aware that you can install aliases during the npm i command, but I am curious as to how TypeScript is doing it.

When I run npm i typescript -g , I can execute tsc afterwards. How is this alias made?

When you globally installed Typescript, the executable creates a symlink for you.
You can view all installed packages npm -g --list .

/usr/local/bin/tsc -> /usr/local/lib/node_modules/typescript/bin/tsc
/usr/local/bin/tsserver -> /usr/local/lib/node_modules/typescript/bin/tsserver

npm i <pkg_name> installs a package into your project. I don't believe it installs aliases. Packages are install in your project's node_modules folder.

If I am understanding your question correctly, you want to set up a script executable from the command line like: npm run myalias .

Alternatively, you can add aliases to your command line: alias rm='rm -i'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM