{ "githubRoot": "https://github.com/nrwl/nx/blob/master", "name": "node", "packageName": "@nrwl/node", "description": "The Node Plugin for Nx contains generators and executors to manage Node applications within an Nx workspace.", "root": "/packages/node", "source": "/packages/node/src", "documentation": [ { "id": "overview", "name": "Overview", "path": "/packages/node", "file": "shared/node-plugin", "content": "The Node Plugin contains generators and executors to manage Node applications within an Nx workspace. It provides:\n\n## Setting Up Node\n\nTo add the Node plugin to an existing workspace, run one of the following:\n\n```bash\n# For npm users\nnpm install -D @nrwl/node\n\n# For yarn users\nyarn add -D @nrwl/node\n```\n\n### Creating Applications\n\nYou can add a new application with the following:\n\n```bash\nnx g @nrwl/node:application my-new-app\n```\n\nYou can run your application with `nx serve my-new-app`, which starts it in watch mode.\n\n### Creating Libraries\n\nNode libraries are a good way to separate features within your organization. To create a Node library run the following command:\n\n```bash\nnx g @nrwl/js:node my-new-lib\n\n# If you want the library to be buildable or publishable to npm\nnx g @nrwl/node:lib my-new-lib --buildable\nnx g @nrwl/node:lib my-new-lib \\\n--publishable \\\n--importPath=@myorg/my-new-lib\n```\n\n## Using Node\n\n### Testing Projects\n\nYou can run unit tests with:\n\n```bash\nnx test my-new-app\nnx test my-new-lib\n```\n\nReplace `my-new-app` with the name or your project. This command works for both applications and libraries.\n\n### Building Projects\n\nNode applications can be build with:\n\n```bash\nnx build my-new-app\n```\n\nAnd if you generated a library with `--buildable`, then you can build a library as well:\n\n```bash\nnx build my-new-lib\n```\n\nThe output is in the `dist` folder. You can customize the output folder by setting `outputPath` in the project's `project.json` file.\n\n### Application Proxies\n\nGenerating Node applications has an option to configure other projects in the workspace to proxy API requests. This can be done by passing the `--frontendProject` with the project name you wish to enable proxy support for.\n\n```bash\nnx g @nrwl/node:application my-new-app \\\n--frontendProject my-react-app\n```\n\n### Debugging\n\nDebugging is set to use a random port that is available on the system. The port can be changed by setting the port option in the `serve` architect in the project.json. Or by running the serve command with `--port `.\n\nFor additional information on how to debug Node applications, see the [Node.js debugging getting started guide](https://nodejs.org/en/docs/guides/debugging-getting-started/#inspector-clients).\n\n## More Documentation\n\n- [Using Cypress](/packages/cypress)\n- [Using Jest](/packages/jest)\n" } ], "generators": [ { "name": "init", "factory": "./src/generators/init/init", "schema": { "$schema": "http://json-schema.org/schema", "cli": "nx", "$id": "NxNodeInit", "title": "Init Node Plugin", "description": "Init Node Plugin.", "type": "object", "properties": { "unitTestRunner": { "description": "Adds the specified unit test runner.", "type": "string", "enum": ["jest", "none"], "default": "jest" }, "skipFormat": { "description": "Skip formatting files.", "type": "boolean", "default": false }, "js": { "type": "boolean", "default": false, "description": "Use JavaScript instead of TypeScript" } }, "required": [], "presets": [] }, "description": "Initialize the `@nrwl/node` plugin.", "aliases": ["ng-add"], "hidden": true, "implementation": "/packages/node/src/generators/init/init.ts", "path": "/packages/node/src/generators/init/schema.json" }, { "name": "application", "factory": "./src/generators/application/application", "schema": { "$schema": "http://json-schema.org/schema", "cli": "nx", "$id": "SchematicsNxNodeApp", "title": "Nx Application Options Schema", "description": "Nx Application Options Schema.", "type": "object", "properties": { "name": { "description": "The name of the application.", "type": "string", "$default": { "$source": "argv", "index": 0 }, "x-prompt": "What name would you like to use for the node application?" }, "directory": { "description": "The directory of the new application.", "type": "string" }, "skipFormat": { "description": "Skip formatting files", "type": "boolean", "default": false }, "skipPackageJson": { "type": "boolean", "default": false, "description": "Do not add dependencies to `package.json`." }, "linter": { "description": "The tool to use for running lint checks.", "type": "string", "enum": ["eslint", "tslint"], "default": "eslint" }, "unitTestRunner": { "type": "string", "enum": ["jest", "none"], "description": "Test runner to use for unit tests.", "default": "jest" }, "tags": { "type": "string", "description": "Add tags to the application (used for linting)." }, "frontendProject": { "type": "string", "description": "Frontend project that needs to access this application. This sets up proxy configuration." }, "babelJest": { "type": "boolean", "description": "Use `babel` instead of `ts-jest`.", "default": false }, "pascalCaseFiles": { "type": "boolean", "description": "Use pascal case file names.", "alias": "P", "default": false }, "js": { "type": "boolean", "description": "Generate JavaScript files rather than TypeScript files.", "default": false }, "setParserOptionsProject": { "type": "boolean", "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.", "default": false }, "standaloneConfig": { "description": "Split the project configuration into `/project.json` rather than including it inside `workspace.json`.", "type": "boolean" } }, "required": [], "presets": [] }, "aliases": ["app"], "x-type": "application", "description": "Create a node application.", "implementation": "/packages/node/src/generators/application/application.ts", "hidden": false, "path": "/packages/node/src/generators/application/schema.json" }, { "name": "library", "factory": "./src/generators/library/library", "schema": { "$schema": "http://json-schema.org/schema", "cli": "nx", "$id": "NxNodeLibrary", "title": "Create a Node Library for Nx", "description": "Create a Node Library for an Nx workspace.", "type": "object", "examples": [ { "command": "nx g lib mylib --directory=myapp", "description": "Generate `libs/myapp/mylib`" } ], "properties": { "name": { "type": "string", "description": "Library name", "$default": { "$source": "argv", "index": 0 }, "x-prompt": "What name would you like to use for the library?" }, "directory": { "type": "string", "description": "A directory where the lib is placed", "alias": "dir" }, "simpleModuleName": { "description": "Keep the module name simple (when using `--directory`).", "type": "boolean", "default": false }, "linter": { "description": "The tool to use for running lint checks.", "type": "string", "enum": ["eslint", "tslint"], "default": "eslint" }, "unitTestRunner": { "type": "string", "enum": ["jest", "none"], "description": "Test runner to use for unit tests.", "default": "jest" }, "tags": { "type": "string", "description": "Add tags to the library (used for linting).", "alias": "t" }, "skipFormat": { "description": "Skip formatting files.", "type": "boolean", "default": false }, "skipTsConfig": { "type": "boolean", "default": false, "description": "Do not update `tsconfig.base.json` for development experience." }, "publishable": { "type": "boolean", "description": "Create a publishable library." }, "buildable": { "type": "boolean", "default": false, "description": "Generate a buildable library." }, "compiler": { "type": "string", "enum": ["tsc", "swc"], "default": "tsc", "description": "The compiler used by the build and test targets." }, "importPath": { "type": "string", "description": "The library name used to import it, like `@myorg/my-awesome-lib`. Must be a valid npm name." }, "rootDir": { "type": "string", "description": "Sets the `rootDir` for TypeScript compilation. When not defined, it uses the project's root property, or `srcRootForCompilationRoot` if it is defined." }, "testEnvironment": { "type": "string", "enum": ["jsdom", "node"], "description": "The test environment to use if `unitTestRunner` is set to `jest`.", "default": "jsdom" }, "babelJest": { "type": "boolean", "description": "Use `babel` instead of `ts-jest`.", "default": false }, "pascalCaseFiles": { "type": "boolean", "description": "Use pascal case file names.", "alias": "P", "default": false }, "js": { "type": "boolean", "description": "Generate JavaScript files rather than TypeScript files.", "default": false }, "strict": { "type": "boolean", "description": "Whether to enable tsconfig strict mode or not.", "default": false }, "standaloneConfig": { "description": "Split the project configuration into `/project.json` rather than including it inside `workspace.json`.", "type": "boolean" }, "setParserOptionsProject": { "type": "boolean", "description": "Whether or not to configure the ESLint `parserOptions.project`. We do not do this by default for lint performance reasons.", "default": false } }, "required": ["name"], "presets": [] }, "aliases": ["lib"], "x-type": "library", "description": "Create a node library.", "implementation": "/packages/node/src/generators/library/library.ts", "hidden": false, "path": "/packages/node/src/generators/library/schema.json" } ], "executors": [ { "name": "webpack", "implementation": "/packages/node/src/executors/webpack/webpack.impl.ts", "schema": { "title": "Node Application Build Target", "description": "Node application build target options for Build Facade.", "cli": "nx", "type": "object", "properties": { "main": { "type": "string", "description": "The name of the main entry-point file.", "x-completion-type": "file", "x-completion-glob": "main@(.js|.ts)" }, "tsConfig": { "type": "string", "description": "The name of the Typescript configuration file.", "x-completion-type": "file", "x-completion-glob": "tsconfig.*.json" }, "outputPath": { "type": "string", "description": "The output path of the generated files.", "x-completion-type": "directory" }, "deleteOutputPath": { "type": "boolean", "description": "Delete the output path before building.", "default": true }, "watch": { "type": "boolean", "description": "Run build when files change.", "default": false }, "watchOptions": { "type": "object", "description": "A set of options used to customize watch mode.", "properties": { "aggregateTimeout": { "type": "integer" }, "ignored": { "oneOf": [ { "type": "array", "items": { "type": "string" } }, { "type": "string" } ] }, "poll": { "type": "integer" }, "followSymlinks": { "type": "boolean" }, "stdin": { "type": "boolean" } } }, "poll": { "type": "number", "description": "Frequency of file watcher in ms." }, "sourceMap": { "type": "boolean", "description": "Produce source maps.", "default": true }, "progress": { "type": "boolean", "description": "Log progress to the console while building.", "default": false }, "assets": { "type": "array", "description": "List of static application assets.", "default": [], "items": { "oneOf": [ { "type": "object", "properties": { "glob": { "type": "string", "description": "The pattern to match." }, "input": { "type": "string", "description": "The input directory path in which to apply `glob`. Defaults to the project root." }, "ignore": { "description": "An array of globs to ignore.", "type": "array", "items": { "type": "string" } }, "output": { "type": "string", "description": "Absolute path within the output." } }, "additionalProperties": false, "required": ["glob", "input", "output"] }, { "type": "string" } ] } }, "externalDependencies": { "oneOf": [ { "type": "string", "enum": ["none", "all"] }, { "type": "array", "items": { "type": "string" } } ], "description": "Dependencies to keep external to the bundle. (`all` (default), `none`, or an array of module names)", "default": "all" }, "statsJson": { "type": "boolean", "description": "Generates a `stats.json` file which can be analyzed using tools such as: `webpack-bundle-analyzer` or ``.", "default": false }, "verbose": { "type": "boolean", "description": "Emits verbose output", "default": false }, "extractLicenses": { "type": "boolean", "description": "Extract all licenses in a separate file, in the case of production builds only.", "default": false }, "optimization": { "type": "boolean", "description": "Defines the optimization level of the build.", "default": false }, "maxWorkers": { "type": "number", "description": "Number of workers to use for type checking. (defaults to # of CPUS)" }, "memoryLimit": { "type": "number", "description": "Memory limit for type checking service process in MB. (defaults to `2048`)", "default": 2048 }, "fileReplacements": { "description": "Replace files with other files in the build.", "type": "array", "items": { "type": "object", "properties": { "replace": { "type": "string", "description": "The file to be replaced.", "x-completion-type": "file" }, "with": { "type": "string", "description": "The file to replace with.", "x-completion-type": "file" } }, "additionalProperties": false, "required": ["replace", "with"] }, "default": [] }, "webpackConfig": { "oneOf": [ { "type": "array", "items": { "type": "string", "x-completion-type": "file", "x-completion-glob": "webpack?(*)@(.js|.ts)" } }, { "type": "string", "x-completion-type": "file", "x-completion-glob": "webpack?(*)@(.js|.ts)" } ], "description": "Path to a function which takes a webpack config, context and returns the resulting webpack config. See https://nx.dev/guides/customize-webpack" }, "buildLibsFromSource": { "type": "boolean", "description": "Read buildable libraries from source instead of building them separately.", "default": true }, "generatePackageJson": { "type": "boolean", "description": "Generates a `package.json` file with the project's `node_module` dependencies populated for installing in a container. If a `package.json` exists in the project's directory, it will be reused with dependencies populated.", "default": false }, "transformers": { "type": "array", "description": "List of TypeScript Compiler Transfomers Plugins.", "default": [], "aliases": ["tsPlugins"], "items": { "oneOf": [ { "type": "string" }, { "type": "object", "properties": { "name": { "type": "string" }, "options": { "type": "object", "additionalProperties": true } }, "additionalProperties": false, "required": ["name"] } ] } }, "additionalEntryPoints": { "type": "array", "items": { "type": "object", "properties": { "entryName": { "type": "string", "description": "Name of the additional entry file." }, "entryPath": { "type": "string", "description": "Path to the additional entry file.", "x-completion-type": "file", "x-completion-glob": "**/*@(.js|.ts)" } } } }, "outputFileName": { "type": "string", "description": "Name of the main output file. (defaults to `main.js`)", "default": "main.js" } }, "required": ["tsConfig", "main"], "definitions": { "assetPattern": { "oneOf": [ { "type": "object", "properties": { "glob": { "type": "string", "description": "The pattern to match." }, "input": { "type": "string", "description": "The input directory path in which to apply `glob`. Defaults to the project root." }, "ignore": { "description": "An array of globs to ignore.", "type": "array", "items": { "type": "string" } }, "output": { "type": "string", "description": "Absolute path within the output." } }, "additionalProperties": false, "required": ["glob", "input", "output"] }, { "type": "string" } ] }, "transformerPattern": { "oneOf": [ { "type": "string" }, { "type": "object", "properties": { "name": { "type": "string" }, "options": { "type": "object", "additionalProperties": true } }, "additionalProperties": false, "required": ["name"] } ] } }, "presets": [] }, "description": "Build a Node application using Webpack.", "aliases": [], "hidden": false, "path": "/packages/node/src/executors/webpack/schema.json" }, { "name": "node", "implementation": "/packages/node/src/executors/node/node.impl.ts", "schema": { "$schema": "http://json-schema.org/schema", "cli": "nx", "title": "Node executor", "description": "Execute Nodejs applications.", "type": "object", "properties": { "buildTarget": { "type": "string", "description": "The target to run to build you the app." }, "buildTargetOptions": { "type": "object", "description": "Additional options to pass into the build target.", "default": {} }, "waitUntilTargets": { "type": "array", "description": "The targets to run to before starting the node app.", "default": [], "items": { "type": "string" } }, "host": { "type": "string", "default": "localhost", "description": "The host to inspect the process on." }, "port": { "type": "number", "default": 9229, "description": "The port to inspect the process on. Setting port to 0 will assign random free ports to all forked processes." }, "inspect": { "oneOf": [ { "type": "string", "enum": ["inspect", "inspect-brk"] }, { "type": "boolean" } ], "description": "Ensures the app is starting with debugging.", "default": "inspect" }, "runtimeArgs": { "type": "array", "description": "Extra args passed to the node process.", "default": [], "items": { "type": "string" } }, "args": { "type": "array", "description": "Extra args when starting the app.", "default": [], "items": { "type": "string" } }, "watch": { "type": "boolean", "description": "Enable re-building when files change.", "default": true } }, "additionalProperties": false, "required": ["buildTarget"], "presets": [] }, "description": "Execute a Node application.", "aliases": [], "hidden": false, "path": "/packages/node/src/executors/node/schema.json" } ] }