@modern-js/create
provides many configuration parameters to configure its behavior during execution, which can be viewed using the --help
parameter:
The following will provide a detailed introduction to these parameters:
The project directory name.
When executing @modern-js/create
, a projectDir
folder will be created in the current directory by default, and the project will be initialized in this folder. If this parameter is empty, the initialization project will be directly generated in the current directory.
If the contents of the directory where projectDir
is located are not empty, a prompt will be given whether to continue creating. It is recommended to perform project initialization operations in an empty directory.
Get the version of the @modern-js/create
tool.
The execution language, supports zh
and en
.
By default, @modern-js/create
will automatically identify the user's system language and choose to use Chinese or English. If the identification fails or does not meet usage habits, you can manually specify it using this parameter.
Specify the default project configuration.
By default, @modern-js/create
will prompt for interactive questions such as language selection and package managers during the execution process. When it is necessary to specify these configuration contents in advance, they can be passed in through this field.
This field is a JSON string. For example, when specifying a package manager:
Supported parameters for config
can be found at Configuration Parameters。
Display debug logs.
When encountering problems during use, you can use this parameter to display debug logs, which is convenient for quickly locating the problem position and troubleshooting.
Quickly create a Web App project.
Quickly create a Npm Module project.
Specify a generator plugin.
@modern-js/create
supports customizing the default project solution type of Modern.js or adding project solution type scenarios using generator plugin. For details, please refer to Developing Generator Plugin.
Specify a micro-generator.
@modern-js/create
supports completely customizing the project generation process using micro-generator.
Specify the version of the generator and Modern.js-related dependencies.
During the execution of @modern-js/create
, a smaller micro-generator will be executed by default, and the latest
version of the micro-generator will be used by default. This parameter can be used to specify the version number of the micro-generator to be executed and the version of the installed Modern.js-related dependencies.
For example, use the next
version:
Specify specific package version dependencies when creating a project.
If you need to specify a specific package version when creating a project, you can use this parameter. This parameter will configure pnpm.overrides
(if the package manager is pnpm) or resolutions
to lock the package version number in the package.json
file in the project root directory.
The parameter value is a JSON string.
For example, specify the react version:
Specify the sub-generator to execute and the npm registry to fetch project dependencies version.
Ignore automatic installation of dependencies.
By default, @modern-js/create
will automatically install dependencies after creating a project. Using this parameter can ignore the installation of dependencies.
The @modern-js/create
command generates sub-generators cache in the tmp directory of the execution machine by default to speed up the generator execution. This command can be used to delete the cache when it needs to be refreshed or when there are problems with the cache.