A JavaScript package supplies reusable code or development tools to a project. TypeScript projects use ordinary JavaScript packages because the TypeScript compiler produces JavaScript. A package may include type information; when it does not, a separate type declaration package may be available. section 2.6 section 15.0
NPM installs project packages into node_modules. It also follows each package’s declared dependencies and selects versions that satisfy their requirements. The project’s package.json records installed packages: dependencies are part of the application, while devDependencies are tools needed during development. section 5.3
{
"name": "tools",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"tsc-watch": "^6.0.0",
"typescript": "^5.0.2"
}
}
Inspect the package.json example: typescript and tsc-watch appear under devDependencies because they are development tools, not application dependencies. section 5.3
Install the compiler for a web app
In a new webapp folder, run `npm init --yes` to create package.json, then `npm install --save-dev typescript@5.0.2`. This toolchain needs a local TypeScript installation; a globally installed compiler is not a substitute for the project package. section 16.1
Choose the installation scope deliberately. A local package belongs to one project; a global installation makes a tool available from anywhere. Use `npm install --save-dev package@version` for a development tool, or omit `--save-dev` for an application dependency. Version requirements can specify an exact version or a permitted range. section 5.3







