-
-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NX mono-repo cannot find module i18n #1103
Comments
Probably is related with this PR: aralroca/next-translate-plugin#55 |
Same problem, had to change |
This works when running build, but when Im trying to start the production build it fails because of the path. |
Try |
almost the same here: Module not found: Can't resolve ' next-translate/withTranslationClientComponent ' |
@mlnima ensure that the next-translate-plugin is in the same version than next-translate. This internal property is removed and the new version of the plugin uses another one. You should have been warned when installing the dependencies as we are restricting with peerDependencies 🤔 |
Thank You, it was my bad 🙂 |
This is an update about what I did for other people who are facing the same issue using next-translate, |
Duplicated of #1121 (comment) |
What version of this package are you using?
"next-translate": "^2.4.4",
Related packages:
"next-translate-plugin": "^2.4.4",
"i18next": "^23.2.8",
"next": "13.4.9",
"nx": "16.2.2",
"@nx/next": "16.4.2",
What operating system, Node.js, and npm version?
OS: macOS Monterey 12.5.1
Node: v20.2.0 (also tested with node 16)
Yarn: 1.22.19
What happened?
Trying to provide path to the i18n.json file in a mono-repo application using NX.
.env:
NEXT_TRANSLATE_PATH=./apps/basic
next.config.json:
`
/* eslint-disable @typescript-eslint/no-var-requires */
const withNx = require('@nx/next/plugins/with-nx');
const nextTranslate = require('next-translate-plugin');
const withImages = require('next-images');
/**
**/
const nextConfig = {
images: {
domains: [
...
],
},
nx: {
// Set this to true if you would like to to use SVGR
// See: https://github.com/gregberge/svgr
svgr: false,
},
publicRuntimeConfig: {
env: {
...
},
},
modularizeImports: {
'@mui/material': {
transform: '@mui/material/{{member}}',
},
'@mui/icons-material': {
transform: '@mui/icons-material/{{member}}',
},
},
};
module.exports = withNx(withImages(nextTranslate(nextConfig)));
`
Error when running "yarn nx run basic:build":
at Module._resolveFilename (node:internal/modules/cjs/loader:1070:15)
at /Users/andersbs/Documents/GitHub/xpand-frontend/node_modules/next/dist/server/require-hook.js:185:36
at Module._load (node:internal/modules/cjs/loader:923:27)
at Module.require (node:internal/modules/cjs/loader:1137:19)
at require (node:internal/modules/helpers:121:18)
at nextTranslate (/Users/andersbs/Documents/GitHub/xpand-frontend/node_modules/next-translate-plugin/lib/cjs/index.js:26:14)
at Object. (/Users/andersbs/Documents/GitHub/xpand-frontend/apps/basic/next.config.js:68:36)
at Module._compile (node:internal/modules/cjs/loader:1255:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1309:10)
at Module.load (node:internal/modules/cjs/loader:1113:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/andersbs/Documents/GitHub/xpand-frontend/node_modules/next-translate-plugin/lib/cjs/index.js',
'/Users/andersbs/Documents/GitHub/xpand-frontend/apps/basic/next.config.js'
]
}
Error occurred while trying to run the npx next build
Error: Command failed: npx next build
at checkExecSyncError (node:child_process:885:11)
at execSync (node:child_process:957:15)
at /Users/andersbs/Documents/GitHub/xpand-frontend/node_modules/@nx/next/src/executors/build/build.impl.js:49:42
at Generator.next ()
at /Users/andersbs/Documents/GitHub/xpand-frontend/node_modules/tslib/tslib.js:169:75
at new Promise ()
at Object.__awaiter (/Users/andersbs/Documents/GitHub/xpand-frontend/node_modules/tslib/tslib.js:165:16)
at buildExecutor (/Users/andersbs/Documents/GitHub/xpand-frontend/node_modules/@nx/next/src/executors/build/build.impl.js:20:20)
at /Users/andersbs/Documents/GitHub/xpand-frontend/node_modules/nx/src/command-line/run/run.js:101:23
What did you expect to happen?
According to the docs "NEXT_TRANSLATE_PATH=./apps/basic" should do the trick. This has also worked in earlier versions.
Expected path:
/Users/andersbs/Documents/GitHub/xpand-frontend/apps/basic/i18n
Actual path which causes the error:
/Users/andersbs/Documents/GitHub/xpand-frontend/apps/basic/apps/basic/apps/basic/i18n
Are you willing to submit a pull request to fix this bug?
Yes
The text was updated successfully, but these errors were encountered: