Intlayer command undefined
Overview
The Intlayer CLI provides a convenient way to control your intlayer content, including building dictionaries, pushing translations, and more. However, it's not essential for your project to work. If you're using the bundler plugin (like withIntlayer() for Next.js or intlayer() for Vite), Intlayer will automatically build dictionaries during app build or development server startup. In development mode, it will also watch for changes and rebuild content declaration files automatically.
You can access the intlayer commands in different ways:
- Using the intlayer cli command directly
- Using the VSCode extension
- Using the @intlayer/cli SDK
Problem
When trying to use the intlayer command, you might encounter this error:
'intlayer' is not recognized as an internal or external command,operable program or batch file.Solutions
Try these solutions in order:
- Verify the command is installed
npx intlayer -hExpected output:
Usage: intlayer [options] [command]Intlayer CLIOptions: -V, --version output the version number -h, --help display help for commandCommands: dictionary|dictionaries Dictionaries operations configuration|config Configuration operations help [command] display help for command- Install the intlayer-cli package globally
npm install intlayer-cli -g -gIt should not be necessary if you've already installed intlayer package
- Install the package globally
npm install intlayer -gRestart your terminal Sometimes a terminal restart is needed to recognize new commands.
Clean and reinstall If the above solutions don't work:
rm -rf node_modules package-lock.jsonnpm installVerify installation files If the issue persists, check that these files exist:
- node_modules/intlayer/dist/cjs/cli.cjs
- node_modules/intlayer/package.json (should have a bin field referencing ./dist/cjs/cli.cjs)
Check PATH environment variable Make sure the npm global bin directory is in your PATH:
# For Unix-based systems (macOS/Linux)echo $PATH# Should include something like /usr/local/bin or ~/.npm-global/bin# For Windowsecho %PATH%# Should include the npm global bin directory- Use npx with full path If the command is still not found, try using npx with the full path:
npx ./node_modules/intlayer/ dictionaries build- Check for conflicting installations
# List all globally installed packagesnpm list -g --depth=0# Remove any conflicting global installationsnpm uninstall -g intlayernpm uninstall -g intlayer-cli# Then reinstallnpm install -g intlayer- Verify Node.js and npm versions Make sure you're using compatible versions:
node --versionnpm --versionIf you're using an outdated version, consider updating Node.js and npm.Check for permission issues If you're getting permission errors:
# For Unix-based systemssudo npm install -g intlayer# Or change npm's default directorymkdir ~/.npm-globalnpm config set prefix '~/.npm-global'# Add to your ~/.profile or ~/.bashrc:export PATH=~/.npm-global/bin:$PATH