Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Add --no-gitignore option"v8.6.43/31/2026
- "Add init command"v7.5.912/30/2025
If you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
Initialize Intlayer
Copy the code to the clipboard
npx intlayer initThe init command automatically sets up Intlayer in your project by configuring necessary files and settings. It's the recommended way to get started with Intlayer.
Aliases:
npx intlayer init
Arguments:
--project-root [projectRoot]- Optional. Specify the project root directory. If not provided, the command will search for the project root starting from the current working directory.--no-gitignore- Optional. Skip the automatic update of the.gitignorefile. If this flag is set,.intlayerwill not be added to.gitignore.
What it does:
The init command performs the following setup tasks:
- Validates project structure - Ensures you're in a valid project directory with a
package.jsonfile - Updates
.gitignore- Adds.intlayerto your.gitignorefile to exclude generated files from version control (can be skipped with--no-gitignore) - Configures TypeScript - Updates all
tsconfig.jsonfiles to include Intlayer type definitions (.intlayer/**/*.ts) - Creates configuration file - Generates an
intlayer.config.ts(for TypeScript projects) orintlayer.config.mjs(for JavaScript projects) with default settings - Updates Vite config - If a Vite configuration file is detected, adds the
vite-intlayerplugin import - Updates Next.js config - If a Next.js configuration file is detected, adds the
next-intlayerplugin import
Examples:
Basic initialization:
Copy the code to the clipboard
npx intlayer initThis will initialize Intlayer in the current directory, automatically detecting the project root.
Initialize with custom project root:
Copy the code to the clipboard
npx intlayer init --project-root ./my-projectThis will initialize Intlayer in the specified directory.
Initialize without updating .gitignore:
Copy the code to the clipboard
npx intlayer init --no-gitignoreThis will set up all configuration files but will not modify your .gitignore.
Example output:
Copy the code to the clipboard
npx intlayer initChecking Intlayer configuration...✓ Added .intlayer to .gitignore✓ Updated tsconfig.json to include intlayer types✓ Created intlayer.config.ts✓ Injected import into vite.config.ts✓ Intlayer init setup complete.Notes:
- The command is idempotent - you can run it multiple times safely. It will skip steps that are already configured.
- If a configuration file already exists, it won't be overwritten.
- TypeScript config files without an
includearray (e.g., solution-style configs with references) are skipped. - The command will exit with an error if no
package.jsonis found in the project root.