nest-cli
nest-cli (opens in a new tab) is a CLI tool for Nest applications, but also can support others Node.js projects. If you had experience with nodemon, you will like nest-cli: support multiple entries config and build.
Why nest-cli
- Like
nodemon
, automatically restarting the node application when file changes in the directory are detected - Support build and multiple entries config
Usage
Create nest-cli.json
:
nest-cli.json
{
"collection": "@nestjs/schematics",
"monorepo": true,
"root": "./",
"sourceRoot": "src",
"entryFile": "main",
"compilerOptions": {
"webpack": false,
"tsConfigPath": "tsconfig.json"
}
}
There are 3 fields need considerations:
root
- Current root foldersourceRoot
- The code folderentryFile
- Entry file filename
Run dev
pnpm nest start --watch
Build
pnpm nest build
Multiple entries
nest-cli.json
{
"collection": "@nestjs/schematics",
"monorepo": true,
"root": "./",
"sourceRoot": "src",
"entryFile": "main",
"compilerOptions": {
"webpack": false,
"tsConfigPath": "tsconfig.json"
},
"projects": {
"hello": {
"type": "application",
"sourceRoot": "src",
"entryFile": "modules/hello/main",
"nodeExternalsParams": {
"additionalModuleDirs": ["./node_modules"]
}
},
"foo": {
"type": "application",
"sourceRoot": "src",
"entryFile": "modules/foo/main",
"nodeExternalsParams": {
"additionalModuleDirs": ["./node_modules"]
}
}
}
}
Run certain module in dev mode
pnpm nest start hello --watch
Build certain modules
pnpm tsdk --nest build hello