I get an error related to sub-packages @intlayer/*
This problem usually occurs after an update of the Intlayer packages.
Example of error message:
Copy the code to the clipboard
Error: Cannot find module '@intlayer/types'Copy the code to the clipboard
TypeError: (0 , __intlayer_config_client.colorize) is not a functionat import { colorize } from '@intlayer/config';Copy the code to the clipboard
✖ ERROR No matching export in "node_modules/@intlayer/config/dist/esm/client.mjs" for import "clearModuleCache"node_modules/@intlayer/unmerged-dictionaries-entry/dist/esm/index.mjs:3:9:3 | import { clearModuleCache, configESMxCJSRequire } from "@intlayer/config"; | ~~~~~~~~~~~~~~~~✖ ERROR No matching export in "node_modules/@intlayer/config/dist/esm/client.mjs" for import "configESMxCJSRequire"node_modules/@intlayer/unmerged-dictionaries-entry/dist/esm/index.mjs:3:27:3 | import { clearModuleCache, configESMxCJSRequire } from "@intlayer/config"; | ~~~~~~~~~~~~~~~~~~~~Reason
Base packages as intlayer, react-intlayer, react-native-intlayer, vue-intlayer are reusing the same sub-packages as @intlayer/config, @intlayer/core, @intlayer/types to avoid code duplication.
Between two versions, the exports of the sub-packages are not guaranteed to be the same. To limit this problem, intlayer pins the version of the sub-packages to the version of the main package.
Ex: intlayer@1.0.0 uses @intlayer/config@1.0.0, @intlayer/core@1.0.0, @intlayer/types@1.0.0
(Except for @intlayer/swc), @intlayer/* sub-packages are not meant to be used directly. So we recommend to do not install them directly.
Resolution
- Ensure the versions of the main package and the sub-packages are the same.
Copy the code to the clipboard
{ "dependencies": { "intlayer": "7.0.1", "react-intlayer": "7.0.0", // Wrong version, it should be 7.0.1 }, "devDependencies": { "intlayer-editor": "7.0.1", },}- Try to remove the lockfile and node_modules folder and reinstall the dependencies.
Sometimes, the package manager keep an old version of the sub-packages in the lockfile in cache. To fix this, you can try to remove the lockfile and node_modules folder and reinstall the dependencies.
Copy the code to the clipboard
rm -rf package-lock.json node_modulesnpm install # or yarn install or pnpm install or bun pm install- Check local dependencies versions
It can happen that your package manager keep an old version of the sub-packages in the lockfile in cache.
Example intlayer@7.0.0 > @intlayer/config@7.0.0 > @intlayer/dictionary-entry@6.0.0.
To detect a mismatch between the local dependencies versions and the sub-packages versions, you can use the following command:
Copy the code to the clipboard
npm list --depth=3 | grep intlayerCopy the code to the clipboard
yarn list --depth=3 | grep intlayerCopy the code to the clipboard
pnpm list --depth=3 | grep intlayerCopy the code to the clipboard
bun pm ls --depth=3 | grep intlayerOn windows, replace | grep intlayer by | findstr intlayer or using PowerShell with Select-String -Pattern "intlayer".
- Check global installation
We recommend to install intlayer or intlayer-cli globally to access the CLI commands. If the global version is not the same as the local version, the package manager may consider the wrong version.
Check if a package is installed globally
Copy the code to the clipboard
npm list -g --depth=3 | grep intlayerCopy the code to the clipboard
yarn global list --depth=3 | grep intlayerCopy the code to the clipboard
pnpm list -g --depth=3 | grep intlayerCopy the code to the clipboard
bun pm ls -g --depth=3 | grep intlayerOn windows, replace | grep intlayer by | findstr intlayer or using PowerShell with Select-String -Pattern "intlayer".
Fix potential global dependency conflicts
Copy the code to the clipboard
npm uninstall -g intlayer intlayer-cliCopy the code to the clipboard
yarn global remove intlayer intlayer-cliCopy the code to the clipboard
pnpm remove -g intlayer intlayer-cliCopy the code to the clipboard
bun pm rm -g intlayer intlayer-cli- Try cleaning the cache
For some environments as docker, github actions, or web hosting platforms as Vercel, a cache can be present. You can try to clean the cache and retry the installation.
You can also try to clean the cache of your package manager with the following command:
Copy the code to the clipboard
npm cache clean --forceCopy the code to the clipboard
yarn cache cleanCopy the code to the clipboard
pnpm cache cleanCopy the code to the clipboard
bun pm cache clean- Try removing the .intlayer folder
Intlayer cache a bundled version of his version itself in the .intlayer/cache folder.
This cache can be corrupted if the version of intlayer is not the same as the version of the cached version.
You can try to remove the .intlayer folder and retry the build.
Copy the code to the clipboard
rm -rf .intlayer